id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
163,200
puniverse/capsule
capsule-util/src/main/java/co/paralleluniverse/capsule/CapsuleLauncher.java
CapsuleLauncher.enableJMX
public static List<String> enableJMX(List<String> jvmArgs) { final String arg = "-D" + OPT_JMX_REMOTE; if (jvmArgs.contains(arg)) return jvmArgs; final List<String> cmdLine2 = new ArrayList<>(jvmArgs); cmdLine2.add(arg); return cmdLine2; }
java
public static List<String> enableJMX(List<String> jvmArgs) { final String arg = "-D" + OPT_JMX_REMOTE; if (jvmArgs.contains(arg)) return jvmArgs; final List<String> cmdLine2 = new ArrayList<>(jvmArgs); cmdLine2.add(arg); return cmdLine2; }
[ "public", "static", "List", "<", "String", ">", "enableJMX", "(", "List", "<", "String", ">", "jvmArgs", ")", "{", "final", "String", "arg", "=", "\"-D\"", "+", "OPT_JMX_REMOTE", ";", "if", "(", "jvmArgs", ".", "contains", "(", "arg", ")", ")", "return", "jvmArgs", ";", "final", "List", "<", "String", ">", "cmdLine2", "=", "new", "ArrayList", "<>", "(", "jvmArgs", ")", ";", "cmdLine2", ".", "add", "(", "arg", ")", ";", "return", "cmdLine2", ";", "}" ]
Adds an option to the JVM arguments to enable JMX connection @param jvmArgs the JVM args @return a new list of JVM args
[ "Adds", "an", "option", "to", "the", "JVM", "arguments", "to", "enable", "JMX", "connection" ]
291a54e501a32aaf0284707b8c1fbff6a566822b
https://github.com/puniverse/capsule/blob/291a54e501a32aaf0284707b8c1fbff6a566822b/capsule-util/src/main/java/co/paralleluniverse/capsule/CapsuleLauncher.java#L272-L279
163,201
vitalidze/chromecast-java-api-v2
src/main/java/su/litvak/chromecast/api/v2/ChromeCast.java
ChromeCast.setVolumeByIncrement
public final void setVolumeByIncrement(float level) throws IOException { Volume volume = this.getStatus().volume; float total = volume.level; if (volume.increment <= 0f) { throw new ChromeCastException("Volume.increment is <= 0"); } // With floating points we always have minor decimal variations, using the Math.min/max // works around this issue // Increase volume if (level > total) { while (total < level) { total = Math.min(total + volume.increment, level); setVolume(total); } // Decrease Volume } else if (level < total) { while (total > level) { total = Math.max(total - volume.increment, level); setVolume(total); } } }
java
public final void setVolumeByIncrement(float level) throws IOException { Volume volume = this.getStatus().volume; float total = volume.level; if (volume.increment <= 0f) { throw new ChromeCastException("Volume.increment is <= 0"); } // With floating points we always have minor decimal variations, using the Math.min/max // works around this issue // Increase volume if (level > total) { while (total < level) { total = Math.min(total + volume.increment, level); setVolume(total); } // Decrease Volume } else if (level < total) { while (total > level) { total = Math.max(total - volume.increment, level); setVolume(total); } } }
[ "public", "final", "void", "setVolumeByIncrement", "(", "float", "level", ")", "throws", "IOException", "{", "Volume", "volume", "=", "this", ".", "getStatus", "(", ")", ".", "volume", ";", "float", "total", "=", "volume", ".", "level", ";", "if", "(", "volume", ".", "increment", "<=", "0f", ")", "{", "throw", "new", "ChromeCastException", "(", "\"Volume.increment is <= 0\"", ")", ";", "}", "// With floating points we always have minor decimal variations, using the Math.min/max", "// works around this issue", "// Increase volume", "if", "(", "level", ">", "total", ")", "{", "while", "(", "total", "<", "level", ")", "{", "total", "=", "Math", ".", "min", "(", "total", "+", "volume", ".", "increment", ",", "level", ")", ";", "setVolume", "(", "total", ")", ";", "}", "// Decrease Volume", "}", "else", "if", "(", "level", "<", "total", ")", "{", "while", "(", "total", ">", "level", ")", "{", "total", "=", "Math", ".", "max", "(", "total", "-", "volume", ".", "increment", ",", "level", ")", ";", "setVolume", "(", "total", ")", ";", "}", "}", "}" ]
ChromeCast does not allow you to jump levels too quickly to avoid blowing speakers. Setting by increment allows us to easily get the level we want @param level volume level from 0 to 1 to set @throws IOException @see <a href="https://developers.google.com/cast/docs/design_checklist/sender#sender-control-volume">sender</a>
[ "ChromeCast", "does", "not", "allow", "you", "to", "jump", "levels", "too", "quickly", "to", "avoid", "blowing", "speakers", ".", "Setting", "by", "increment", "allows", "us", "to", "easily", "get", "the", "level", "we", "want" ]
3d8c0d7e735464f1cb64c5aa349e486d18a3b2ad
https://github.com/vitalidze/chromecast-java-api-v2/blob/3d8c0d7e735464f1cb64c5aa349e486d18a3b2ad/src/main/java/su/litvak/chromecast/api/v2/ChromeCast.java#L300-L323
163,202
vitalidze/chromecast-java-api-v2
src/main/java/su/litvak/chromecast/api/v2/Channel.java
Channel.connect
private void connect() throws IOException, GeneralSecurityException { synchronized (closedSync) { if (socket == null || socket.isClosed()) { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, new TrustManager[] { new X509TrustAllManager() }, new SecureRandom()); socket = sc.getSocketFactory().createSocket(); socket.connect(address); } /** * Authenticate */ CastChannel.DeviceAuthMessage authMessage = CastChannel.DeviceAuthMessage.newBuilder() .setChallenge(CastChannel.AuthChallenge.newBuilder().build()) .build(); CastChannel.CastMessage msg = CastChannel.CastMessage.newBuilder() .setDestinationId(DEFAULT_RECEIVER_ID) .setNamespace("urn:x-cast:com.google.cast.tp.deviceauth") .setPayloadType(CastChannel.CastMessage.PayloadType.BINARY) .setProtocolVersion(CastChannel.CastMessage.ProtocolVersion.CASTV2_1_0) .setSourceId(name) .setPayloadBinary(authMessage.toByteString()) .build(); write(msg); CastChannel.CastMessage response = read(); CastChannel.DeviceAuthMessage authResponse = CastChannel.DeviceAuthMessage.parseFrom(response.getPayloadBinary()); if (authResponse.hasError()) { throw new ChromeCastException("Authentication failed: " + authResponse.getError().getErrorType().toString()); } /** * Send 'PING' message */ PingThread pingThread = new PingThread(); pingThread.run(); /** * Send 'CONNECT' message to start session */ write("urn:x-cast:com.google.cast.tp.connection", StandardMessage.connect(), DEFAULT_RECEIVER_ID); /** * Start ping/pong and reader thread */ pingTimer = new Timer(name + " PING"); pingTimer.schedule(pingThread, 1000, PING_PERIOD); reader = new ReadThread(); reader.start(); if (closed) { closed = false; notifyListenerOfConnectionEvent(true); } } }
java
private void connect() throws IOException, GeneralSecurityException { synchronized (closedSync) { if (socket == null || socket.isClosed()) { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, new TrustManager[] { new X509TrustAllManager() }, new SecureRandom()); socket = sc.getSocketFactory().createSocket(); socket.connect(address); } /** * Authenticate */ CastChannel.DeviceAuthMessage authMessage = CastChannel.DeviceAuthMessage.newBuilder() .setChallenge(CastChannel.AuthChallenge.newBuilder().build()) .build(); CastChannel.CastMessage msg = CastChannel.CastMessage.newBuilder() .setDestinationId(DEFAULT_RECEIVER_ID) .setNamespace("urn:x-cast:com.google.cast.tp.deviceauth") .setPayloadType(CastChannel.CastMessage.PayloadType.BINARY) .setProtocolVersion(CastChannel.CastMessage.ProtocolVersion.CASTV2_1_0) .setSourceId(name) .setPayloadBinary(authMessage.toByteString()) .build(); write(msg); CastChannel.CastMessage response = read(); CastChannel.DeviceAuthMessage authResponse = CastChannel.DeviceAuthMessage.parseFrom(response.getPayloadBinary()); if (authResponse.hasError()) { throw new ChromeCastException("Authentication failed: " + authResponse.getError().getErrorType().toString()); } /** * Send 'PING' message */ PingThread pingThread = new PingThread(); pingThread.run(); /** * Send 'CONNECT' message to start session */ write("urn:x-cast:com.google.cast.tp.connection", StandardMessage.connect(), DEFAULT_RECEIVER_ID); /** * Start ping/pong and reader thread */ pingTimer = new Timer(name + " PING"); pingTimer.schedule(pingThread, 1000, PING_PERIOD); reader = new ReadThread(); reader.start(); if (closed) { closed = false; notifyListenerOfConnectionEvent(true); } } }
[ "private", "void", "connect", "(", ")", "throws", "IOException", ",", "GeneralSecurityException", "{", "synchronized", "(", "closedSync", ")", "{", "if", "(", "socket", "==", "null", "||", "socket", ".", "isClosed", "(", ")", ")", "{", "SSLContext", "sc", "=", "SSLContext", ".", "getInstance", "(", "\"SSL\"", ")", ";", "sc", ".", "init", "(", "null", ",", "new", "TrustManager", "[", "]", "{", "new", "X509TrustAllManager", "(", ")", "}", ",", "new", "SecureRandom", "(", ")", ")", ";", "socket", "=", "sc", ".", "getSocketFactory", "(", ")", ".", "createSocket", "(", ")", ";", "socket", ".", "connect", "(", "address", ")", ";", "}", "/**\n * Authenticate\n */", "CastChannel", ".", "DeviceAuthMessage", "authMessage", "=", "CastChannel", ".", "DeviceAuthMessage", ".", "newBuilder", "(", ")", ".", "setChallenge", "(", "CastChannel", ".", "AuthChallenge", ".", "newBuilder", "(", ")", ".", "build", "(", ")", ")", ".", "build", "(", ")", ";", "CastChannel", ".", "CastMessage", "msg", "=", "CastChannel", ".", "CastMessage", ".", "newBuilder", "(", ")", ".", "setDestinationId", "(", "DEFAULT_RECEIVER_ID", ")", ".", "setNamespace", "(", "\"urn:x-cast:com.google.cast.tp.deviceauth\"", ")", ".", "setPayloadType", "(", "CastChannel", ".", "CastMessage", ".", "PayloadType", ".", "BINARY", ")", ".", "setProtocolVersion", "(", "CastChannel", ".", "CastMessage", ".", "ProtocolVersion", ".", "CASTV2_1_0", ")", ".", "setSourceId", "(", "name", ")", ".", "setPayloadBinary", "(", "authMessage", ".", "toByteString", "(", ")", ")", ".", "build", "(", ")", ";", "write", "(", "msg", ")", ";", "CastChannel", ".", "CastMessage", "response", "=", "read", "(", ")", ";", "CastChannel", ".", "DeviceAuthMessage", "authResponse", "=", "CastChannel", ".", "DeviceAuthMessage", ".", "parseFrom", "(", "response", ".", "getPayloadBinary", "(", ")", ")", ";", "if", "(", "authResponse", ".", "hasError", "(", ")", ")", "{", "throw", "new", "ChromeCastException", "(", "\"Authentication failed: \"", "+", "authResponse", ".", "getError", "(", ")", ".", "getErrorType", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "/**\n * Send 'PING' message\n */", "PingThread", "pingThread", "=", "new", "PingThread", "(", ")", ";", "pingThread", ".", "run", "(", ")", ";", "/**\n * Send 'CONNECT' message to start session\n */", "write", "(", "\"urn:x-cast:com.google.cast.tp.connection\"", ",", "StandardMessage", ".", "connect", "(", ")", ",", "DEFAULT_RECEIVER_ID", ")", ";", "/**\n * Start ping/pong and reader thread\n */", "pingTimer", "=", "new", "Timer", "(", "name", "+", "\" PING\"", ")", ";", "pingTimer", ".", "schedule", "(", "pingThread", ",", "1000", ",", "PING_PERIOD", ")", ";", "reader", "=", "new", "ReadThread", "(", ")", ";", "reader", ".", "start", "(", ")", ";", "if", "(", "closed", ")", "{", "closed", "=", "false", ";", "notifyListenerOfConnectionEvent", "(", "true", ")", ";", "}", "}", "}" ]
Establish connection to the ChromeCast device
[ "Establish", "connection", "to", "the", "ChromeCast", "device" ]
3d8c0d7e735464f1cb64c5aa349e486d18a3b2ad
https://github.com/vitalidze/chromecast-java-api-v2/blob/3d8c0d7e735464f1cb64c5aa349e486d18a3b2ad/src/main/java/su/litvak/chromecast/api/v2/Channel.java#L288-L344
163,203
komamitsu/fluency
fluency-core/src/main/java/org/komamitsu/fluency/util/ExecutorServiceUtils.java
ExecutorServiceUtils.newSingleThreadDaemonExecutor
public static ExecutorService newSingleThreadDaemonExecutor() { return Executors.newSingleThreadExecutor(r -> { Thread t = Executors.defaultThreadFactory().newThread(r); t.setDaemon(true); return t; }); }
java
public static ExecutorService newSingleThreadDaemonExecutor() { return Executors.newSingleThreadExecutor(r -> { Thread t = Executors.defaultThreadFactory().newThread(r); t.setDaemon(true); return t; }); }
[ "public", "static", "ExecutorService", "newSingleThreadDaemonExecutor", "(", ")", "{", "return", "Executors", ".", "newSingleThreadExecutor", "(", "r", "->", "{", "Thread", "t", "=", "Executors", ".", "defaultThreadFactory", "(", ")", ".", "newThread", "(", "r", ")", ";", "t", ".", "setDaemon", "(", "true", ")", ";", "return", "t", ";", "}", ")", ";", "}" ]
Creates an Executor that is based on daemon threads. This allows the program to quit without explicitly calling shutdown on the pool @return the newly created single-threaded Executor
[ "Creates", "an", "Executor", "that", "is", "based", "on", "daemon", "threads", ".", "This", "allows", "the", "program", "to", "quit", "without", "explicitly", "calling", "shutdown", "on", "the", "pool" ]
76d07ba292d2666d143eaaedb28be97deb928a38
https://github.com/komamitsu/fluency/blob/76d07ba292d2666d143eaaedb28be97deb928a38/fluency-core/src/main/java/org/komamitsu/fluency/util/ExecutorServiceUtils.java#L38-L44
163,204
komamitsu/fluency
fluency-core/src/main/java/org/komamitsu/fluency/util/ExecutorServiceUtils.java
ExecutorServiceUtils.newScheduledDaemonThreadPool
public static ScheduledExecutorService newScheduledDaemonThreadPool(int corePoolSize) { return Executors.newScheduledThreadPool(corePoolSize, r -> { Thread t = Executors.defaultThreadFactory().newThread(r); t.setDaemon(true); return t; }); }
java
public static ScheduledExecutorService newScheduledDaemonThreadPool(int corePoolSize) { return Executors.newScheduledThreadPool(corePoolSize, r -> { Thread t = Executors.defaultThreadFactory().newThread(r); t.setDaemon(true); return t; }); }
[ "public", "static", "ScheduledExecutorService", "newScheduledDaemonThreadPool", "(", "int", "corePoolSize", ")", "{", "return", "Executors", ".", "newScheduledThreadPool", "(", "corePoolSize", ",", "r", "->", "{", "Thread", "t", "=", "Executors", ".", "defaultThreadFactory", "(", ")", ".", "newThread", "(", "r", ")", ";", "t", ".", "setDaemon", "(", "true", ")", ";", "return", "t", ";", "}", ")", ";", "}" ]
Creates a scheduled thread pool where each thread has the daemon property set to true. This allows the program to quit without explicitly calling shutdown on the pool @param corePoolSize the number of threads to keep in the pool, even if they are idle @return a newly created scheduled thread pool
[ "Creates", "a", "scheduled", "thread", "pool", "where", "each", "thread", "has", "the", "daemon", "property", "set", "to", "true", ".", "This", "allows", "the", "program", "to", "quit", "without", "explicitly", "calling", "shutdown", "on", "the", "pool" ]
76d07ba292d2666d143eaaedb28be97deb928a38
https://github.com/komamitsu/fluency/blob/76d07ba292d2666d143eaaedb28be97deb928a38/fluency-core/src/main/java/org/komamitsu/fluency/util/ExecutorServiceUtils.java#L56-L62
163,205
SimonVT/android-menudrawer
menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java
MenuDrawer.createMenuDrawer
private static MenuDrawer createMenuDrawer(Activity activity, int dragMode, Position position, Type type) { MenuDrawer drawer; if (type == Type.STATIC) { drawer = new StaticDrawer(activity); } else if (type == Type.OVERLAY) { drawer = new OverlayDrawer(activity, dragMode); if (position == Position.LEFT || position == Position.START) { drawer.setupUpIndicator(activity); } } else { drawer = new SlidingDrawer(activity, dragMode); if (position == Position.LEFT || position == Position.START) { drawer.setupUpIndicator(activity); } } drawer.mDragMode = dragMode; drawer.setPosition(position); return drawer; }
java
private static MenuDrawer createMenuDrawer(Activity activity, int dragMode, Position position, Type type) { MenuDrawer drawer; if (type == Type.STATIC) { drawer = new StaticDrawer(activity); } else if (type == Type.OVERLAY) { drawer = new OverlayDrawer(activity, dragMode); if (position == Position.LEFT || position == Position.START) { drawer.setupUpIndicator(activity); } } else { drawer = new SlidingDrawer(activity, dragMode); if (position == Position.LEFT || position == Position.START) { drawer.setupUpIndicator(activity); } } drawer.mDragMode = dragMode; drawer.setPosition(position); return drawer; }
[ "private", "static", "MenuDrawer", "createMenuDrawer", "(", "Activity", "activity", ",", "int", "dragMode", ",", "Position", "position", ",", "Type", "type", ")", "{", "MenuDrawer", "drawer", ";", "if", "(", "type", "==", "Type", ".", "STATIC", ")", "{", "drawer", "=", "new", "StaticDrawer", "(", "activity", ")", ";", "}", "else", "if", "(", "type", "==", "Type", ".", "OVERLAY", ")", "{", "drawer", "=", "new", "OverlayDrawer", "(", "activity", ",", "dragMode", ")", ";", "if", "(", "position", "==", "Position", ".", "LEFT", "||", "position", "==", "Position", ".", "START", ")", "{", "drawer", ".", "setupUpIndicator", "(", "activity", ")", ";", "}", "}", "else", "{", "drawer", "=", "new", "SlidingDrawer", "(", "activity", ",", "dragMode", ")", ";", "if", "(", "position", "==", "Position", ".", "LEFT", "||", "position", "==", "Position", ".", "START", ")", "{", "drawer", ".", "setupUpIndicator", "(", "activity", ")", ";", "}", "}", "drawer", ".", "mDragMode", "=", "dragMode", ";", "drawer", ".", "setPosition", "(", "position", ")", ";", "return", "drawer", ";", "}" ]
Constructs the appropriate MenuDrawer based on the position.
[ "Constructs", "the", "appropriate", "MenuDrawer", "based", "on", "the", "position", "." ]
59e8d18e109c77d911b8b63232d66d5f0551cf6a
https://github.com/SimonVT/android-menudrawer/blob/59e8d18e109c77d911b8b63232d66d5f0551cf6a/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java#L478-L501
163,206
SimonVT/android-menudrawer
menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java
MenuDrawer.attachToContent
private static void attachToContent(Activity activity, MenuDrawer menuDrawer) { /** * Do not call mActivity#setContentView. * E.g. if using with a ListActivity, Activity#setContentView is overridden and dispatched to * MenuDrawer#setContentView, which then again would call Activity#setContentView. */ ViewGroup content = (ViewGroup) activity.findViewById(android.R.id.content); content.removeAllViews(); content.addView(menuDrawer, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); }
java
private static void attachToContent(Activity activity, MenuDrawer menuDrawer) { /** * Do not call mActivity#setContentView. * E.g. if using with a ListActivity, Activity#setContentView is overridden and dispatched to * MenuDrawer#setContentView, which then again would call Activity#setContentView. */ ViewGroup content = (ViewGroup) activity.findViewById(android.R.id.content); content.removeAllViews(); content.addView(menuDrawer, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); }
[ "private", "static", "void", "attachToContent", "(", "Activity", "activity", ",", "MenuDrawer", "menuDrawer", ")", "{", "/**\n * Do not call mActivity#setContentView.\n * E.g. if using with a ListActivity, Activity#setContentView is overridden and dispatched to\n * MenuDrawer#setContentView, which then again would call Activity#setContentView.\n */", "ViewGroup", "content", "=", "(", "ViewGroup", ")", "activity", ".", "findViewById", "(", "android", ".", "R", ".", "id", ".", "content", ")", ";", "content", ".", "removeAllViews", "(", ")", ";", "content", ".", "addView", "(", "menuDrawer", ",", "LayoutParams", ".", "MATCH_PARENT", ",", "LayoutParams", ".", "MATCH_PARENT", ")", ";", "}" ]
Attaches the menu drawer to the content view.
[ "Attaches", "the", "menu", "drawer", "to", "the", "content", "view", "." ]
59e8d18e109c77d911b8b63232d66d5f0551cf6a
https://github.com/SimonVT/android-menudrawer/blob/59e8d18e109c77d911b8b63232d66d5f0551cf6a/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java#L506-L515
163,207
SimonVT/android-menudrawer
menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java
MenuDrawer.attachToDecor
private static void attachToDecor(Activity activity, MenuDrawer menuDrawer) { ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); ViewGroup decorChild = (ViewGroup) decorView.getChildAt(0); decorView.removeAllViews(); decorView.addView(menuDrawer, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); menuDrawer.mContentContainer.addView(decorChild, decorChild.getLayoutParams()); }
java
private static void attachToDecor(Activity activity, MenuDrawer menuDrawer) { ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); ViewGroup decorChild = (ViewGroup) decorView.getChildAt(0); decorView.removeAllViews(); decorView.addView(menuDrawer, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); menuDrawer.mContentContainer.addView(decorChild, decorChild.getLayoutParams()); }
[ "private", "static", "void", "attachToDecor", "(", "Activity", "activity", ",", "MenuDrawer", "menuDrawer", ")", "{", "ViewGroup", "decorView", "=", "(", "ViewGroup", ")", "activity", ".", "getWindow", "(", ")", ".", "getDecorView", "(", ")", ";", "ViewGroup", "decorChild", "=", "(", "ViewGroup", ")", "decorView", ".", "getChildAt", "(", "0", ")", ";", "decorView", ".", "removeAllViews", "(", ")", ";", "decorView", ".", "addView", "(", "menuDrawer", ",", "LayoutParams", ".", "MATCH_PARENT", ",", "LayoutParams", ".", "MATCH_PARENT", ")", ";", "menuDrawer", ".", "mContentContainer", ".", "addView", "(", "decorChild", ",", "decorChild", ".", "getLayoutParams", "(", ")", ")", ";", "}" ]
Attaches the menu drawer to the window.
[ "Attaches", "the", "menu", "drawer", "to", "the", "window", "." ]
59e8d18e109c77d911b8b63232d66d5f0551cf6a
https://github.com/SimonVT/android-menudrawer/blob/59e8d18e109c77d911b8b63232d66d5f0551cf6a/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java#L520-L528
163,208
SimonVT/android-menudrawer
menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java
MenuDrawer.setActiveView
public void setActiveView(View v, int position) { final View oldView = mActiveView; mActiveView = v; mActivePosition = position; if (mAllowIndicatorAnimation && oldView != null) { startAnimatingIndicator(); } invalidate(); }
java
public void setActiveView(View v, int position) { final View oldView = mActiveView; mActiveView = v; mActivePosition = position; if (mAllowIndicatorAnimation && oldView != null) { startAnimatingIndicator(); } invalidate(); }
[ "public", "void", "setActiveView", "(", "View", "v", ",", "int", "position", ")", "{", "final", "View", "oldView", "=", "mActiveView", ";", "mActiveView", "=", "v", ";", "mActivePosition", "=", "position", ";", "if", "(", "mAllowIndicatorAnimation", "&&", "oldView", "!=", "null", ")", "{", "startAnimatingIndicator", "(", ")", ";", "}", "invalidate", "(", ")", ";", "}" ]
Set the active view. If the mdActiveIndicator attribute is set, this View will have the indicator drawn next to it. @param v The active view. @param position Optional position, usually used with ListView. v.setTag(R.id.mdActiveViewPosition, position) must be called first.
[ "Set", "the", "active", "view", ".", "If", "the", "mdActiveIndicator", "attribute", "is", "set", "this", "View", "will", "have", "the", "indicator", "drawn", "next", "to", "it", "." ]
59e8d18e109c77d911b8b63232d66d5f0551cf6a
https://github.com/SimonVT/android-menudrawer/blob/59e8d18e109c77d911b8b63232d66d5f0551cf6a/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java#L1005-L1015
163,209
SimonVT/android-menudrawer
menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java
MenuDrawer.getIndicatorStartPos
private int getIndicatorStartPos() { switch (getPosition()) { case TOP: return mIndicatorClipRect.left; case RIGHT: return mIndicatorClipRect.top; case BOTTOM: return mIndicatorClipRect.left; default: return mIndicatorClipRect.top; } }
java
private int getIndicatorStartPos() { switch (getPosition()) { case TOP: return mIndicatorClipRect.left; case RIGHT: return mIndicatorClipRect.top; case BOTTOM: return mIndicatorClipRect.left; default: return mIndicatorClipRect.top; } }
[ "private", "int", "getIndicatorStartPos", "(", ")", "{", "switch", "(", "getPosition", "(", ")", ")", "{", "case", "TOP", ":", "return", "mIndicatorClipRect", ".", "left", ";", "case", "RIGHT", ":", "return", "mIndicatorClipRect", ".", "top", ";", "case", "BOTTOM", ":", "return", "mIndicatorClipRect", ".", "left", ";", "default", ":", "return", "mIndicatorClipRect", ".", "top", ";", "}", "}" ]
Returns the start position of the indicator. @return The start position of the indicator.
[ "Returns", "the", "start", "position", "of", "the", "indicator", "." ]
59e8d18e109c77d911b8b63232d66d5f0551cf6a
https://github.com/SimonVT/android-menudrawer/blob/59e8d18e109c77d911b8b63232d66d5f0551cf6a/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java#L1071-L1082
163,210
SimonVT/android-menudrawer
menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java
MenuDrawer.animateIndicatorInvalidate
private void animateIndicatorInvalidate() { if (mIndicatorScroller.computeScrollOffset()) { mIndicatorOffset = mIndicatorScroller.getCurr(); invalidate(); if (!mIndicatorScroller.isFinished()) { postOnAnimation(mIndicatorRunnable); return; } } completeAnimatingIndicator(); }
java
private void animateIndicatorInvalidate() { if (mIndicatorScroller.computeScrollOffset()) { mIndicatorOffset = mIndicatorScroller.getCurr(); invalidate(); if (!mIndicatorScroller.isFinished()) { postOnAnimation(mIndicatorRunnable); return; } } completeAnimatingIndicator(); }
[ "private", "void", "animateIndicatorInvalidate", "(", ")", "{", "if", "(", "mIndicatorScroller", ".", "computeScrollOffset", "(", ")", ")", "{", "mIndicatorOffset", "=", "mIndicatorScroller", ".", "getCurr", "(", ")", ";", "invalidate", "(", ")", ";", "if", "(", "!", "mIndicatorScroller", ".", "isFinished", "(", ")", ")", "{", "postOnAnimation", "(", "mIndicatorRunnable", ")", ";", "return", ";", "}", "}", "completeAnimatingIndicator", "(", ")", ";", "}" ]
Callback when each frame in the indicator animation should be drawn.
[ "Callback", "when", "each", "frame", "in", "the", "indicator", "animation", "should", "be", "drawn", "." ]
59e8d18e109c77d911b8b63232d66d5f0551cf6a
https://github.com/SimonVT/android-menudrawer/blob/59e8d18e109c77d911b8b63232d66d5f0551cf6a/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java#L1100-L1112
163,211
SimonVT/android-menudrawer
menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java
MenuDrawer.setDropShadowColor
public void setDropShadowColor(int color) { GradientDrawable.Orientation orientation = getDropShadowOrientation(); final int endColor = color & 0x00FFFFFF; mDropShadowDrawable = new GradientDrawable(orientation, new int[] { color, endColor, }); invalidate(); }
java
public void setDropShadowColor(int color) { GradientDrawable.Orientation orientation = getDropShadowOrientation(); final int endColor = color & 0x00FFFFFF; mDropShadowDrawable = new GradientDrawable(orientation, new int[] { color, endColor, }); invalidate(); }
[ "public", "void", "setDropShadowColor", "(", "int", "color", ")", "{", "GradientDrawable", ".", "Orientation", "orientation", "=", "getDropShadowOrientation", "(", ")", ";", "final", "int", "endColor", "=", "color", "&", "0x00FFFFFF", ";", "mDropShadowDrawable", "=", "new", "GradientDrawable", "(", "orientation", ",", "new", "int", "[", "]", "{", "color", ",", "endColor", ",", "}", ")", ";", "invalidate", "(", ")", ";", "}" ]
Sets the color of the drop shadow. @param color The color of the drop shadow.
[ "Sets", "the", "color", "of", "the", "drop", "shadow", "." ]
59e8d18e109c77d911b8b63232d66d5f0551cf6a
https://github.com/SimonVT/android-menudrawer/blob/59e8d18e109c77d911b8b63232d66d5f0551cf6a/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java#L1196-L1206
163,212
SimonVT/android-menudrawer
menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java
MenuDrawer.setSlideDrawable
public void setSlideDrawable(Drawable drawable) { mSlideDrawable = new SlideDrawable(drawable); mSlideDrawable.setIsRtl(ViewHelper.getLayoutDirection(this) == LAYOUT_DIRECTION_RTL); if (mActionBarHelper != null) { mActionBarHelper.setDisplayShowHomeAsUpEnabled(true); if (mDrawerIndicatorEnabled) { mActionBarHelper.setActionBarUpIndicator(mSlideDrawable, isMenuVisible() ? mDrawerOpenContentDesc : mDrawerClosedContentDesc); } } }
java
public void setSlideDrawable(Drawable drawable) { mSlideDrawable = new SlideDrawable(drawable); mSlideDrawable.setIsRtl(ViewHelper.getLayoutDirection(this) == LAYOUT_DIRECTION_RTL); if (mActionBarHelper != null) { mActionBarHelper.setDisplayShowHomeAsUpEnabled(true); if (mDrawerIndicatorEnabled) { mActionBarHelper.setActionBarUpIndicator(mSlideDrawable, isMenuVisible() ? mDrawerOpenContentDesc : mDrawerClosedContentDesc); } } }
[ "public", "void", "setSlideDrawable", "(", "Drawable", "drawable", ")", "{", "mSlideDrawable", "=", "new", "SlideDrawable", "(", "drawable", ")", ";", "mSlideDrawable", ".", "setIsRtl", "(", "ViewHelper", ".", "getLayoutDirection", "(", "this", ")", "==", "LAYOUT_DIRECTION_RTL", ")", ";", "if", "(", "mActionBarHelper", "!=", "null", ")", "{", "mActionBarHelper", ".", "setDisplayShowHomeAsUpEnabled", "(", "true", ")", ";", "if", "(", "mDrawerIndicatorEnabled", ")", "{", "mActionBarHelper", ".", "setActionBarUpIndicator", "(", "mSlideDrawable", ",", "isMenuVisible", "(", ")", "?", "mDrawerOpenContentDesc", ":", "mDrawerClosedContentDesc", ")", ";", "}", "}", "}" ]
Sets the drawable used as the drawer indicator. @param drawable The drawable used as the drawer indicator.
[ "Sets", "the", "drawable", "used", "as", "the", "drawer", "indicator", "." ]
59e8d18e109c77d911b8b63232d66d5f0551cf6a
https://github.com/SimonVT/android-menudrawer/blob/59e8d18e109c77d911b8b63232d66d5f0551cf6a/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java#L1323-L1335
163,213
SimonVT/android-menudrawer
menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java
MenuDrawer.getContentContainer
public ViewGroup getContentContainer() { if (mDragMode == MENU_DRAG_CONTENT) { return mContentContainer; } else { return (ViewGroup) findViewById(android.R.id.content); } }
java
public ViewGroup getContentContainer() { if (mDragMode == MENU_DRAG_CONTENT) { return mContentContainer; } else { return (ViewGroup) findViewById(android.R.id.content); } }
[ "public", "ViewGroup", "getContentContainer", "(", ")", "{", "if", "(", "mDragMode", "==", "MENU_DRAG_CONTENT", ")", "{", "return", "mContentContainer", ";", "}", "else", "{", "return", "(", "ViewGroup", ")", "findViewById", "(", "android", ".", "R", ".", "id", ".", "content", ")", ";", "}", "}" ]
Returns the ViewGroup used as a parent for the content view. @return The content view's parent.
[ "Returns", "the", "ViewGroup", "used", "as", "a", "parent", "for", "the", "content", "view", "." ]
59e8d18e109c77d911b8b63232d66d5f0551cf6a
https://github.com/SimonVT/android-menudrawer/blob/59e8d18e109c77d911b8b63232d66d5f0551cf6a/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java#L1397-L1403
163,214
SimonVT/android-menudrawer
menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java
MenuDrawer.setMenuView
public void setMenuView(int layoutResId) { mMenuContainer.removeAllViews(); mMenuView = LayoutInflater.from(getContext()).inflate(layoutResId, mMenuContainer, false); mMenuContainer.addView(mMenuView); }
java
public void setMenuView(int layoutResId) { mMenuContainer.removeAllViews(); mMenuView = LayoutInflater.from(getContext()).inflate(layoutResId, mMenuContainer, false); mMenuContainer.addView(mMenuView); }
[ "public", "void", "setMenuView", "(", "int", "layoutResId", ")", "{", "mMenuContainer", ".", "removeAllViews", "(", ")", ";", "mMenuView", "=", "LayoutInflater", ".", "from", "(", "getContext", "(", ")", ")", ".", "inflate", "(", "layoutResId", ",", "mMenuContainer", ",", "false", ")", ";", "mMenuContainer", ".", "addView", "(", "mMenuView", ")", ";", "}" ]
Set the menu view from a layout resource. @param layoutResId Resource ID to be inflated.
[ "Set", "the", "menu", "view", "from", "a", "layout", "resource", "." ]
59e8d18e109c77d911b8b63232d66d5f0551cf6a
https://github.com/SimonVT/android-menudrawer/blob/59e8d18e109c77d911b8b63232d66d5f0551cf6a/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java#L1410-L1414
163,215
SimonVT/android-menudrawer
menudrawer-samples/src/net/simonvt/menudrawer/samples/BottomDrawerSample.java
BottomDrawerSample.onClick
@Override public void onClick(View v) { String tag = (String) v.getTag(); mContentTextView.setText(String.format("%s clicked.", tag)); mMenuDrawer.setActiveView(v); }
java
@Override public void onClick(View v) { String tag = (String) v.getTag(); mContentTextView.setText(String.format("%s clicked.", tag)); mMenuDrawer.setActiveView(v); }
[ "@", "Override", "public", "void", "onClick", "(", "View", "v", ")", "{", "String", "tag", "=", "(", "String", ")", "v", ".", "getTag", "(", ")", ";", "mContentTextView", ".", "setText", "(", "String", ".", "format", "(", "\"%s clicked.\"", ",", "tag", ")", ")", ";", "mMenuDrawer", ".", "setActiveView", "(", "v", ")", ";", "}" ]
Click handler for bottom drawer items.
[ "Click", "handler", "for", "bottom", "drawer", "items", "." ]
59e8d18e109c77d911b8b63232d66d5f0551cf6a
https://github.com/SimonVT/android-menudrawer/blob/59e8d18e109c77d911b8b63232d66d5f0551cf6a/menudrawer-samples/src/net/simonvt/menudrawer/samples/BottomDrawerSample.java#L37-L42
163,216
SimonVT/android-menudrawer
menudrawer/src/net/simonvt/menudrawer/DraggableDrawer.java
DraggableDrawer.animateOffsetTo
protected void animateOffsetTo(int position, int velocity, boolean animate) { endDrag(); endPeek(); final int startX = (int) mOffsetPixels; final int dx = position - startX; if (dx == 0 || !animate) { setOffsetPixels(position); setDrawerState(position == 0 ? STATE_CLOSED : STATE_OPEN); stopLayerTranslation(); return; } int duration; velocity = Math.abs(velocity); if (velocity > 0) { duration = 4 * Math.round(1000.f * Math.abs((float) dx / velocity)); } else { duration = (int) (600.f * Math.abs((float) dx / mMenuSize)); } duration = Math.min(duration, mMaxAnimationDuration); animateOffsetTo(position, duration); }
java
protected void animateOffsetTo(int position, int velocity, boolean animate) { endDrag(); endPeek(); final int startX = (int) mOffsetPixels; final int dx = position - startX; if (dx == 0 || !animate) { setOffsetPixels(position); setDrawerState(position == 0 ? STATE_CLOSED : STATE_OPEN); stopLayerTranslation(); return; } int duration; velocity = Math.abs(velocity); if (velocity > 0) { duration = 4 * Math.round(1000.f * Math.abs((float) dx / velocity)); } else { duration = (int) (600.f * Math.abs((float) dx / mMenuSize)); } duration = Math.min(duration, mMaxAnimationDuration); animateOffsetTo(position, duration); }
[ "protected", "void", "animateOffsetTo", "(", "int", "position", ",", "int", "velocity", ",", "boolean", "animate", ")", "{", "endDrag", "(", ")", ";", "endPeek", "(", ")", ";", "final", "int", "startX", "=", "(", "int", ")", "mOffsetPixels", ";", "final", "int", "dx", "=", "position", "-", "startX", ";", "if", "(", "dx", "==", "0", "||", "!", "animate", ")", "{", "setOffsetPixels", "(", "position", ")", ";", "setDrawerState", "(", "position", "==", "0", "?", "STATE_CLOSED", ":", "STATE_OPEN", ")", ";", "stopLayerTranslation", "(", ")", ";", "return", ";", "}", "int", "duration", ";", "velocity", "=", "Math", ".", "abs", "(", "velocity", ")", ";", "if", "(", "velocity", ">", "0", ")", "{", "duration", "=", "4", "*", "Math", ".", "round", "(", "1000.f", "*", "Math", ".", "abs", "(", "(", "float", ")", "dx", "/", "velocity", ")", ")", ";", "}", "else", "{", "duration", "=", "(", "int", ")", "(", "600.f", "*", "Math", ".", "abs", "(", "(", "float", ")", "dx", "/", "mMenuSize", ")", ")", ";", "}", "duration", "=", "Math", ".", "min", "(", "duration", ",", "mMaxAnimationDuration", ")", ";", "animateOffsetTo", "(", "position", ",", "duration", ")", ";", "}" ]
Moves the drawer to the position passed. @param position The position the content is moved to. @param velocity Optional velocity if called by releasing a drag event. @param animate Whether the move is animated.
[ "Moves", "the", "drawer", "to", "the", "position", "passed", "." ]
59e8d18e109c77d911b8b63232d66d5f0551cf6a
https://github.com/SimonVT/android-menudrawer/blob/59e8d18e109c77d911b8b63232d66d5f0551cf6a/menudrawer/src/net/simonvt/menudrawer/DraggableDrawer.java#L351-L375
163,217
aeshell/aesh
aesh/src/main/java/org/aesh/parser/ParsedLineIterator.java
ParsedLineIterator.pollParsedWord
public ParsedWord pollParsedWord() { if(hasNextWord()) { //set correct next char if(parsedLine.words().size() > (word+1)) character = parsedLine.words().get(word+1).lineIndex(); else character = -1; return parsedLine.words().get(word++); } else return new ParsedWord(null, -1); }
java
public ParsedWord pollParsedWord() { if(hasNextWord()) { //set correct next char if(parsedLine.words().size() > (word+1)) character = parsedLine.words().get(word+1).lineIndex(); else character = -1; return parsedLine.words().get(word++); } else return new ParsedWord(null, -1); }
[ "public", "ParsedWord", "pollParsedWord", "(", ")", "{", "if", "(", "hasNextWord", "(", ")", ")", "{", "//set correct next char", "if", "(", "parsedLine", ".", "words", "(", ")", ".", "size", "(", ")", ">", "(", "word", "+", "1", ")", ")", "character", "=", "parsedLine", ".", "words", "(", ")", ".", "get", "(", "word", "+", "1", ")", ".", "lineIndex", "(", ")", ";", "else", "character", "=", "-", "1", ";", "return", "parsedLine", ".", "words", "(", ")", ".", "get", "(", "word", "++", ")", ";", "}", "else", "return", "new", "ParsedWord", "(", "null", ",", "-", "1", ")", ";", "}" ]
Polls the next ParsedWord from the stack. @return next ParsedWord
[ "Polls", "the", "next", "ParsedWord", "from", "the", "stack", "." ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/parser/ParsedLineIterator.java#L63-L74
163,218
aeshell/aesh
aesh/src/main/java/org/aesh/parser/ParsedLineIterator.java
ParsedLineIterator.pollChar
public char pollChar() { if(hasNextChar()) { if(hasNextWord() && character+1 >= parsedLine.words().get(word).lineIndex()+ parsedLine.words().get(word).word().length()) word++; return parsedLine.line().charAt(character++); } return '\u0000'; }
java
public char pollChar() { if(hasNextChar()) { if(hasNextWord() && character+1 >= parsedLine.words().get(word).lineIndex()+ parsedLine.words().get(word).word().length()) word++; return parsedLine.line().charAt(character++); } return '\u0000'; }
[ "public", "char", "pollChar", "(", ")", "{", "if", "(", "hasNextChar", "(", ")", ")", "{", "if", "(", "hasNextWord", "(", ")", "&&", "character", "+", "1", ">=", "parsedLine", ".", "words", "(", ")", ".", "get", "(", "word", ")", ".", "lineIndex", "(", ")", "+", "parsedLine", ".", "words", "(", ")", ".", "get", "(", "word", ")", ".", "word", "(", ")", ".", "length", "(", ")", ")", "word", "++", ";", "return", "parsedLine", ".", "line", "(", ")", ".", "charAt", "(", "character", "++", ")", ";", "}", "return", "'", "'", ";", "}" ]
Polls the next char from the stack @return next char
[ "Polls", "the", "next", "char", "from", "the", "stack" ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/parser/ParsedLineIterator.java#L111-L120
163,219
aeshell/aesh
aesh/src/main/java/org/aesh/parser/ParsedLineIterator.java
ParsedLineIterator.updateIteratorPosition
public void updateIteratorPosition(int length) { if(length > 0) { //make sure we dont go OB if((length + character) > parsedLine.line().length()) length = parsedLine.line().length() - character; //move word counter to the correct word while(hasNextWord() && (length + character) >= parsedLine.words().get(word).lineIndex() + parsedLine.words().get(word).word().length()) word++; character = length + character; } else throw new IllegalArgumentException("The length given must be > 0 and not exceed the boundary of the line (including the current position)"); }
java
public void updateIteratorPosition(int length) { if(length > 0) { //make sure we dont go OB if((length + character) > parsedLine.line().length()) length = parsedLine.line().length() - character; //move word counter to the correct word while(hasNextWord() && (length + character) >= parsedLine.words().get(word).lineIndex() + parsedLine.words().get(word).word().length()) word++; character = length + character; } else throw new IllegalArgumentException("The length given must be > 0 and not exceed the boundary of the line (including the current position)"); }
[ "public", "void", "updateIteratorPosition", "(", "int", "length", ")", "{", "if", "(", "length", ">", "0", ")", "{", "//make sure we dont go OB", "if", "(", "(", "length", "+", "character", ")", ">", "parsedLine", ".", "line", "(", ")", ".", "length", "(", ")", ")", "length", "=", "parsedLine", ".", "line", "(", ")", ".", "length", "(", ")", "-", "character", ";", "//move word counter to the correct word", "while", "(", "hasNextWord", "(", ")", "&&", "(", "length", "+", "character", ")", ">=", "parsedLine", ".", "words", "(", ")", ".", "get", "(", "word", ")", ".", "lineIndex", "(", ")", "+", "parsedLine", ".", "words", "(", ")", ".", "get", "(", "word", ")", ".", "word", "(", ")", ".", "length", "(", ")", ")", "word", "++", ";", "character", "=", "length", "+", "character", ";", "}", "else", "throw", "new", "IllegalArgumentException", "(", "\"The length given must be > 0 and not exceed the boundary of the line (including the current position)\"", ")", ";", "}" ]
Update the current position with specified length. The input will append to the current position of the iterator. @param length update length
[ "Update", "the", "current", "position", "with", "specified", "length", ".", "The", "input", "will", "append", "to", "the", "current", "position", "of", "the", "iterator", "." ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/parser/ParsedLineIterator.java#L162-L178
163,220
aeshell/aesh
aesh/src/main/java/org/aesh/command/impl/parser/AeshCommandLineParser.java
AeshCommandLineParser.printHelp
@Override public String printHelp() { List<CommandLineParser<CI>> parsers = getChildParsers(); if (parsers != null && parsers.size() > 0) { StringBuilder sb = new StringBuilder(); sb.append(processedCommand.printHelp(helpNames())) .append(Config.getLineSeparator()) .append(processedCommand.name()) .append(" commands:") .append(Config.getLineSeparator()); int maxLength = 0; for (CommandLineParser child : parsers) { int length = child.getProcessedCommand().name().length(); if (length > maxLength) { maxLength = length; } } for (CommandLineParser child : parsers) { sb.append(child.getFormattedCommand(4, maxLength + 2)) .append(Config.getLineSeparator()); } return sb.toString(); } else return processedCommand.printHelp(helpNames()); }
java
@Override public String printHelp() { List<CommandLineParser<CI>> parsers = getChildParsers(); if (parsers != null && parsers.size() > 0) { StringBuilder sb = new StringBuilder(); sb.append(processedCommand.printHelp(helpNames())) .append(Config.getLineSeparator()) .append(processedCommand.name()) .append(" commands:") .append(Config.getLineSeparator()); int maxLength = 0; for (CommandLineParser child : parsers) { int length = child.getProcessedCommand().name().length(); if (length > maxLength) { maxLength = length; } } for (CommandLineParser child : parsers) { sb.append(child.getFormattedCommand(4, maxLength + 2)) .append(Config.getLineSeparator()); } return sb.toString(); } else return processedCommand.printHelp(helpNames()); }
[ "@", "Override", "public", "String", "printHelp", "(", ")", "{", "List", "<", "CommandLineParser", "<", "CI", ">>", "parsers", "=", "getChildParsers", "(", ")", ";", "if", "(", "parsers", "!=", "null", "&&", "parsers", ".", "size", "(", ")", ">", "0", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "processedCommand", ".", "printHelp", "(", "helpNames", "(", ")", ")", ")", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ".", "append", "(", "processedCommand", ".", "name", "(", ")", ")", ".", "append", "(", "\" commands:\"", ")", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ";", "int", "maxLength", "=", "0", ";", "for", "(", "CommandLineParser", "child", ":", "parsers", ")", "{", "int", "length", "=", "child", ".", "getProcessedCommand", "(", ")", ".", "name", "(", ")", ".", "length", "(", ")", ";", "if", "(", "length", ">", "maxLength", ")", "{", "maxLength", "=", "length", ";", "}", "}", "for", "(", "CommandLineParser", "child", ":", "parsers", ")", "{", "sb", ".", "append", "(", "child", ".", "getFormattedCommand", "(", "4", ",", "maxLength", "+", "2", ")", ")", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "else", "return", "processedCommand", ".", "printHelp", "(", "helpNames", "(", ")", ")", ";", "}" ]
Returns a usage String based on the defined command and options. Useful when printing "help" info etc.
[ "Returns", "a", "usage", "String", "based", "on", "the", "defined", "command", "and", "options", ".", "Useful", "when", "printing", "help", "info", "etc", "." ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/command/impl/parser/AeshCommandLineParser.java#L215-L244
163,221
aeshell/aesh
aesh/src/main/java/org/aesh/command/impl/parser/AeshCommandLineParser.java
AeshCommandLineParser.parse
@Override public void parse(String line, Mode mode) { parse(lineParser.parseLine(line, line.length()).iterator(), mode); }
java
@Override public void parse(String line, Mode mode) { parse(lineParser.parseLine(line, line.length()).iterator(), mode); }
[ "@", "Override", "public", "void", "parse", "(", "String", "line", ",", "Mode", "mode", ")", "{", "parse", "(", "lineParser", ".", "parseLine", "(", "line", ",", "line", ".", "length", "(", ")", ")", ".", "iterator", "(", ")", ",", "mode", ")", ";", "}" ]
Parse a command line with the defined command as base of the rules. If any options are found, but not defined in the command object an CommandLineParserException will be thrown. Also, if a required option is not found or options specified with value, but is not given any value an CommandLineParserException will be thrown. @param line input @param mode parser mode
[ "Parse", "a", "command", "line", "with", "the", "defined", "command", "as", "base", "of", "the", "rules", ".", "If", "any", "options", "are", "found", "but", "not", "defined", "in", "the", "command", "object", "an", "CommandLineParserException", "will", "be", "thrown", ".", "Also", "if", "a", "required", "option", "is", "not", "found", "or", "options", "specified", "with", "value", "but", "is", "not", "given", "any", "value", "an", "CommandLineParserException", "will", "be", "thrown", "." ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/command/impl/parser/AeshCommandLineParser.java#L559-L562
163,222
aeshell/aesh
aesh/src/main/java/org/aesh/command/impl/populator/AeshCommandPopulator.java
AeshCommandPopulator.populateObject
@Override public void populateObject(ProcessedCommand<Command<CI>, CI> processedCommand, InvocationProviders invocationProviders, AeshContext aeshContext, CommandLineParser.Mode mode) throws CommandLineParserException, OptionValidatorException { if(processedCommand.parserExceptions().size() > 0 && mode == CommandLineParser.Mode.VALIDATE) throw processedCommand.parserExceptions().get(0); for(ProcessedOption option : processedCommand.getOptions()) { if(option.getValues() != null && option.getValues().size() > 0) option.injectValueIntoField(getObject(), invocationProviders, aeshContext, mode == CommandLineParser.Mode.VALIDATE ); else if(option.getDefaultValues().size() > 0) { option.injectValueIntoField(getObject(), invocationProviders, aeshContext, mode == CommandLineParser.Mode.VALIDATE); } else if(option.getOptionType().equals(OptionType.GROUP) && option.getProperties().size() > 0) option.injectValueIntoField(getObject(), invocationProviders, aeshContext, mode == CommandLineParser.Mode.VALIDATE); else resetField(getObject(), option.getFieldName(), option.hasValue()); } //arguments if(processedCommand.getArguments() != null && (processedCommand.getArguments().getValues().size() > 0 || processedCommand.getArguments().getDefaultValues().size() > 0)) processedCommand.getArguments().injectValueIntoField(getObject(), invocationProviders, aeshContext, mode == CommandLineParser.Mode.VALIDATE); else if(processedCommand.getArguments() != null) resetField(getObject(), processedCommand.getArguments().getFieldName(), true); //argument if(processedCommand.getArgument() != null && (processedCommand.getArgument().getValues().size() > 0 || processedCommand.getArgument().getDefaultValues().size() > 0)) processedCommand.getArgument().injectValueIntoField(getObject(), invocationProviders, aeshContext, mode == CommandLineParser.Mode.VALIDATE); else if(processedCommand.getArgument() != null) resetField(getObject(), processedCommand.getArgument().getFieldName(), true); }
java
@Override public void populateObject(ProcessedCommand<Command<CI>, CI> processedCommand, InvocationProviders invocationProviders, AeshContext aeshContext, CommandLineParser.Mode mode) throws CommandLineParserException, OptionValidatorException { if(processedCommand.parserExceptions().size() > 0 && mode == CommandLineParser.Mode.VALIDATE) throw processedCommand.parserExceptions().get(0); for(ProcessedOption option : processedCommand.getOptions()) { if(option.getValues() != null && option.getValues().size() > 0) option.injectValueIntoField(getObject(), invocationProviders, aeshContext, mode == CommandLineParser.Mode.VALIDATE ); else if(option.getDefaultValues().size() > 0) { option.injectValueIntoField(getObject(), invocationProviders, aeshContext, mode == CommandLineParser.Mode.VALIDATE); } else if(option.getOptionType().equals(OptionType.GROUP) && option.getProperties().size() > 0) option.injectValueIntoField(getObject(), invocationProviders, aeshContext, mode == CommandLineParser.Mode.VALIDATE); else resetField(getObject(), option.getFieldName(), option.hasValue()); } //arguments if(processedCommand.getArguments() != null && (processedCommand.getArguments().getValues().size() > 0 || processedCommand.getArguments().getDefaultValues().size() > 0)) processedCommand.getArguments().injectValueIntoField(getObject(), invocationProviders, aeshContext, mode == CommandLineParser.Mode.VALIDATE); else if(processedCommand.getArguments() != null) resetField(getObject(), processedCommand.getArguments().getFieldName(), true); //argument if(processedCommand.getArgument() != null && (processedCommand.getArgument().getValues().size() > 0 || processedCommand.getArgument().getDefaultValues().size() > 0)) processedCommand.getArgument().injectValueIntoField(getObject(), invocationProviders, aeshContext, mode == CommandLineParser.Mode.VALIDATE); else if(processedCommand.getArgument() != null) resetField(getObject(), processedCommand.getArgument().getFieldName(), true); }
[ "@", "Override", "public", "void", "populateObject", "(", "ProcessedCommand", "<", "Command", "<", "CI", ">", ",", "CI", ">", "processedCommand", ",", "InvocationProviders", "invocationProviders", ",", "AeshContext", "aeshContext", ",", "CommandLineParser", ".", "Mode", "mode", ")", "throws", "CommandLineParserException", ",", "OptionValidatorException", "{", "if", "(", "processedCommand", ".", "parserExceptions", "(", ")", ".", "size", "(", ")", ">", "0", "&&", "mode", "==", "CommandLineParser", ".", "Mode", ".", "VALIDATE", ")", "throw", "processedCommand", ".", "parserExceptions", "(", ")", ".", "get", "(", "0", ")", ";", "for", "(", "ProcessedOption", "option", ":", "processedCommand", ".", "getOptions", "(", ")", ")", "{", "if", "(", "option", ".", "getValues", "(", ")", "!=", "null", "&&", "option", ".", "getValues", "(", ")", ".", "size", "(", ")", ">", "0", ")", "option", ".", "injectValueIntoField", "(", "getObject", "(", ")", ",", "invocationProviders", ",", "aeshContext", ",", "mode", "==", "CommandLineParser", ".", "Mode", ".", "VALIDATE", ")", ";", "else", "if", "(", "option", ".", "getDefaultValues", "(", ")", ".", "size", "(", ")", ">", "0", ")", "{", "option", ".", "injectValueIntoField", "(", "getObject", "(", ")", ",", "invocationProviders", ",", "aeshContext", ",", "mode", "==", "CommandLineParser", ".", "Mode", ".", "VALIDATE", ")", ";", "}", "else", "if", "(", "option", ".", "getOptionType", "(", ")", ".", "equals", "(", "OptionType", ".", "GROUP", ")", "&&", "option", ".", "getProperties", "(", ")", ".", "size", "(", ")", ">", "0", ")", "option", ".", "injectValueIntoField", "(", "getObject", "(", ")", ",", "invocationProviders", ",", "aeshContext", ",", "mode", "==", "CommandLineParser", ".", "Mode", ".", "VALIDATE", ")", ";", "else", "resetField", "(", "getObject", "(", ")", ",", "option", ".", "getFieldName", "(", ")", ",", "option", ".", "hasValue", "(", ")", ")", ";", "}", "//arguments", "if", "(", "processedCommand", ".", "getArguments", "(", ")", "!=", "null", "&&", "(", "processedCommand", ".", "getArguments", "(", ")", ".", "getValues", "(", ")", ".", "size", "(", ")", ">", "0", "||", "processedCommand", ".", "getArguments", "(", ")", ".", "getDefaultValues", "(", ")", ".", "size", "(", ")", ">", "0", ")", ")", "processedCommand", ".", "getArguments", "(", ")", ".", "injectValueIntoField", "(", "getObject", "(", ")", ",", "invocationProviders", ",", "aeshContext", ",", "mode", "==", "CommandLineParser", ".", "Mode", ".", "VALIDATE", ")", ";", "else", "if", "(", "processedCommand", ".", "getArguments", "(", ")", "!=", "null", ")", "resetField", "(", "getObject", "(", ")", ",", "processedCommand", ".", "getArguments", "(", ")", ".", "getFieldName", "(", ")", ",", "true", ")", ";", "//argument", "if", "(", "processedCommand", ".", "getArgument", "(", ")", "!=", "null", "&&", "(", "processedCommand", ".", "getArgument", "(", ")", ".", "getValues", "(", ")", ".", "size", "(", ")", ">", "0", "||", "processedCommand", ".", "getArgument", "(", ")", ".", "getDefaultValues", "(", ")", ".", "size", "(", ")", ">", "0", ")", ")", "processedCommand", ".", "getArgument", "(", ")", ".", "injectValueIntoField", "(", "getObject", "(", ")", ",", "invocationProviders", ",", "aeshContext", ",", "mode", "==", "CommandLineParser", ".", "Mode", ".", "VALIDATE", ")", ";", "else", "if", "(", "processedCommand", ".", "getArgument", "(", ")", "!=", "null", ")", "resetField", "(", "getObject", "(", ")", ",", "processedCommand", ".", "getArgument", "(", ")", ".", "getFieldName", "(", ")", ",", "true", ")", ";", "}" ]
Populate a Command instance with the values parsed from a command line If any parser errors are detected it will throw an exception @param processedCommand command line @param mode do validation or not @throws CommandLineParserException any incorrectness in the parser will abort the populate
[ "Populate", "a", "Command", "instance", "with", "the", "values", "parsed", "from", "a", "command", "line", "If", "any", "parser", "errors", "are", "detected", "it", "will", "throw", "an", "exception" ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/command/impl/populator/AeshCommandPopulator.java#L55-L89
163,223
aeshell/aesh
aesh/src/main/java/org/aesh/command/impl/internal/ProcessedCommand.java
ProcessedCommand.getOptionLongNamesWithDash
public List<TerminalString> getOptionLongNamesWithDash() { List<ProcessedOption> opts = getOptions(); List<TerminalString> names = new ArrayList<>(opts.size()); for (ProcessedOption o : opts) { if(o.getValues().size() == 0 && o.activator().isActivated(new ParsedCommand(this))) names.add(o.getRenderedNameWithDashes()); } return names; }
java
public List<TerminalString> getOptionLongNamesWithDash() { List<ProcessedOption> opts = getOptions(); List<TerminalString> names = new ArrayList<>(opts.size()); for (ProcessedOption o : opts) { if(o.getValues().size() == 0 && o.activator().isActivated(new ParsedCommand(this))) names.add(o.getRenderedNameWithDashes()); } return names; }
[ "public", "List", "<", "TerminalString", ">", "getOptionLongNamesWithDash", "(", ")", "{", "List", "<", "ProcessedOption", ">", "opts", "=", "getOptions", "(", ")", ";", "List", "<", "TerminalString", ">", "names", "=", "new", "ArrayList", "<>", "(", "opts", ".", "size", "(", ")", ")", ";", "for", "(", "ProcessedOption", "o", ":", "opts", ")", "{", "if", "(", "o", ".", "getValues", "(", ")", ".", "size", "(", ")", "==", "0", "&&", "o", ".", "activator", "(", ")", ".", "isActivated", "(", "new", "ParsedCommand", "(", "this", ")", ")", ")", "names", ".", "add", "(", "o", ".", "getRenderedNameWithDashes", "(", ")", ")", ";", "}", "return", "names", ";", "}" ]
Return all option names that not already have a value and is enabled
[ "Return", "all", "option", "names", "that", "not", "already", "have", "a", "value", "and", "is", "enabled" ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/command/impl/internal/ProcessedCommand.java#L319-L329
163,224
aeshell/aesh
aesh/src/main/java/org/aesh/command/impl/internal/ProcessedCommand.java
ProcessedCommand.printHelp
public String printHelp(String commandName) { int maxLength = 0; int width = 80; List<ProcessedOption> opts = getOptions(); for (ProcessedOption o : opts) { if(o.getFormattedLength() > maxLength) maxLength = o.getFormattedLength(); } StringBuilder sb = new StringBuilder(); //first line sb.append("Usage: "); if(commandName == null || commandName.length() == 0) sb.append(name()); else sb.append(commandName); if(opts.size() > 0) sb.append(" [<options>]"); if(argument != null) { if(argument.isTypeAssignableByResourcesOrFile()) sb.append(" <file>"); else sb.append(" <").append(argument.getFieldName()).append(">"); } if(arguments != null) { if(arguments.isTypeAssignableByResourcesOrFile()) sb.append(" [<files>]"); else sb.append(" [<").append(arguments.getFieldName()).append(">]"); } sb.append(Config.getLineSeparator()); //second line sb.append(description()).append(Config.getLineSeparator()); //options and arguments if (opts.size() > 0) sb.append(Config.getLineSeparator()).append("Options:").append(Config.getLineSeparator()); for (ProcessedOption o : opts) sb.append(o.getFormattedOption(2, maxLength+4, width)).append(Config.getLineSeparator()); if(arguments != null) { sb.append(Config.getLineSeparator()).append("Arguments:").append(Config.getLineSeparator()); sb.append(arguments.getFormattedOption(2, maxLength+4, width)).append(Config.getLineSeparator()); } if(argument != null) { sb.append(Config.getLineSeparator()).append("Argument:").append(Config.getLineSeparator()); sb.append(argument.getFormattedOption(2, maxLength+4, width)).append(Config.getLineSeparator()); } return sb.toString(); }
java
public String printHelp(String commandName) { int maxLength = 0; int width = 80; List<ProcessedOption> opts = getOptions(); for (ProcessedOption o : opts) { if(o.getFormattedLength() > maxLength) maxLength = o.getFormattedLength(); } StringBuilder sb = new StringBuilder(); //first line sb.append("Usage: "); if(commandName == null || commandName.length() == 0) sb.append(name()); else sb.append(commandName); if(opts.size() > 0) sb.append(" [<options>]"); if(argument != null) { if(argument.isTypeAssignableByResourcesOrFile()) sb.append(" <file>"); else sb.append(" <").append(argument.getFieldName()).append(">"); } if(arguments != null) { if(arguments.isTypeAssignableByResourcesOrFile()) sb.append(" [<files>]"); else sb.append(" [<").append(arguments.getFieldName()).append(">]"); } sb.append(Config.getLineSeparator()); //second line sb.append(description()).append(Config.getLineSeparator()); //options and arguments if (opts.size() > 0) sb.append(Config.getLineSeparator()).append("Options:").append(Config.getLineSeparator()); for (ProcessedOption o : opts) sb.append(o.getFormattedOption(2, maxLength+4, width)).append(Config.getLineSeparator()); if(arguments != null) { sb.append(Config.getLineSeparator()).append("Arguments:").append(Config.getLineSeparator()); sb.append(arguments.getFormattedOption(2, maxLength+4, width)).append(Config.getLineSeparator()); } if(argument != null) { sb.append(Config.getLineSeparator()).append("Argument:").append(Config.getLineSeparator()); sb.append(argument.getFormattedOption(2, maxLength+4, width)).append(Config.getLineSeparator()); } return sb.toString(); }
[ "public", "String", "printHelp", "(", "String", "commandName", ")", "{", "int", "maxLength", "=", "0", ";", "int", "width", "=", "80", ";", "List", "<", "ProcessedOption", ">", "opts", "=", "getOptions", "(", ")", ";", "for", "(", "ProcessedOption", "o", ":", "opts", ")", "{", "if", "(", "o", ".", "getFormattedLength", "(", ")", ">", "maxLength", ")", "maxLength", "=", "o", ".", "getFormattedLength", "(", ")", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "//first line", "sb", ".", "append", "(", "\"Usage: \"", ")", ";", "if", "(", "commandName", "==", "null", "||", "commandName", ".", "length", "(", ")", "==", "0", ")", "sb", ".", "append", "(", "name", "(", ")", ")", ";", "else", "sb", ".", "append", "(", "commandName", ")", ";", "if", "(", "opts", ".", "size", "(", ")", ">", "0", ")", "sb", ".", "append", "(", "\" [<options>]\"", ")", ";", "if", "(", "argument", "!=", "null", ")", "{", "if", "(", "argument", ".", "isTypeAssignableByResourcesOrFile", "(", ")", ")", "sb", ".", "append", "(", "\" <file>\"", ")", ";", "else", "sb", ".", "append", "(", "\" <\"", ")", ".", "append", "(", "argument", ".", "getFieldName", "(", ")", ")", ".", "append", "(", "\">\"", ")", ";", "}", "if", "(", "arguments", "!=", "null", ")", "{", "if", "(", "arguments", ".", "isTypeAssignableByResourcesOrFile", "(", ")", ")", "sb", ".", "append", "(", "\" [<files>]\"", ")", ";", "else", "sb", ".", "append", "(", "\" [<\"", ")", ".", "append", "(", "arguments", ".", "getFieldName", "(", ")", ")", ".", "append", "(", "\">]\"", ")", ";", "}", "sb", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ";", "//second line", "sb", ".", "append", "(", "description", "(", ")", ")", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ";", "//options and arguments", "if", "(", "opts", ".", "size", "(", ")", ">", "0", ")", "sb", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ".", "append", "(", "\"Options:\"", ")", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ";", "for", "(", "ProcessedOption", "o", ":", "opts", ")", "sb", ".", "append", "(", "o", ".", "getFormattedOption", "(", "2", ",", "maxLength", "+", "4", ",", "width", ")", ")", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ";", "if", "(", "arguments", "!=", "null", ")", "{", "sb", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ".", "append", "(", "\"Arguments:\"", ")", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ";", "sb", ".", "append", "(", "arguments", ".", "getFormattedOption", "(", "2", ",", "maxLength", "+", "4", ",", "width", ")", ")", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ";", "}", "if", "(", "argument", "!=", "null", ")", "{", "sb", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ".", "append", "(", "\"Argument:\"", ")", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ";", "sb", ".", "append", "(", "argument", ".", "getFormattedOption", "(", "2", ",", "maxLength", "+", "4", ",", "width", ")", ")", ".", "append", "(", "Config", ".", "getLineSeparator", "(", ")", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Returns a description String based on the defined command and options. Useful when printing "help" info etc.
[ "Returns", "a", "description", "String", "based", "on", "the", "defined", "command", "and", "options", ".", "Useful", "when", "printing", "help", "info", "etc", "." ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/command/impl/internal/ProcessedCommand.java#L390-L440
163,225
aeshell/aesh
aesh/src/main/java/org/aesh/command/impl/internal/ProcessedCommand.java
ProcessedCommand.hasUniqueLongOption
public boolean hasUniqueLongOption(String optionName) { if(hasLongOption(optionName)) { for(ProcessedOption o : getOptions()) { if(o.name().startsWith(optionName) && !o.name().equals(optionName)) return false; } return true; } return false; }
java
public boolean hasUniqueLongOption(String optionName) { if(hasLongOption(optionName)) { for(ProcessedOption o : getOptions()) { if(o.name().startsWith(optionName) && !o.name().equals(optionName)) return false; } return true; } return false; }
[ "public", "boolean", "hasUniqueLongOption", "(", "String", "optionName", ")", "{", "if", "(", "hasLongOption", "(", "optionName", ")", ")", "{", "for", "(", "ProcessedOption", "o", ":", "getOptions", "(", ")", ")", "{", "if", "(", "o", ".", "name", "(", ")", ".", "startsWith", "(", "optionName", ")", "&&", "!", "o", ".", "name", "(", ")", ".", "equals", "(", "optionName", ")", ")", "return", "false", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
not start with another option name
[ "not", "start", "with", "another", "option", "name" ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/command/impl/internal/ProcessedCommand.java#L486-L495
163,226
aeshell/aesh
aesh/src/main/java/org/aesh/io/scanner/ClassFileBuffer.java
ClassFileBuffer.seek
public void seek(final int position) throws IOException { if (position < 0) { throw new IllegalArgumentException("position < 0: " + position); } if (position > size) { throw new EOFException(); } this.pointer = position; }
java
public void seek(final int position) throws IOException { if (position < 0) { throw new IllegalArgumentException("position < 0: " + position); } if (position > size) { throw new EOFException(); } this.pointer = position; }
[ "public", "void", "seek", "(", "final", "int", "position", ")", "throws", "IOException", "{", "if", "(", "position", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"position < 0: \"", "+", "position", ")", ";", "}", "if", "(", "position", ">", "size", ")", "{", "throw", "new", "EOFException", "(", ")", ";", "}", "this", ".", "pointer", "=", "position", ";", "}" ]
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.
[ "Sets", "the", "file", "-", "pointer", "offset", "measured", "from", "the", "beginning", "of", "this", "file", "at", "which", "the", "next", "read", "or", "write", "occurs", "." ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/io/scanner/ClassFileBuffer.java#L87-L95
163,227
aeshell/aesh
aesh/src/main/java/org/aesh/command/settings/SettingsImpl.java
SettingsImpl.editMode
@Override public EditMode editMode() { if(readInputrc) { try { return EditModeBuilder.builder().parseInputrc(new FileInputStream(inputrc())).create(); } catch(FileNotFoundException e) { return EditModeBuilder.builder(mode()).create(); } } else return EditModeBuilder.builder(mode()).create(); }
java
@Override public EditMode editMode() { if(readInputrc) { try { return EditModeBuilder.builder().parseInputrc(new FileInputStream(inputrc())).create(); } catch(FileNotFoundException e) { return EditModeBuilder.builder(mode()).create(); } } else return EditModeBuilder.builder(mode()).create(); }
[ "@", "Override", "public", "EditMode", "editMode", "(", ")", "{", "if", "(", "readInputrc", ")", "{", "try", "{", "return", "EditModeBuilder", ".", "builder", "(", ")", ".", "parseInputrc", "(", "new", "FileInputStream", "(", "inputrc", "(", ")", ")", ")", ".", "create", "(", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "return", "EditModeBuilder", ".", "builder", "(", "mode", "(", ")", ")", ".", "create", "(", ")", ";", "}", "}", "else", "return", "EditModeBuilder", ".", "builder", "(", "mode", "(", ")", ")", ".", "create", "(", ")", ";", "}" ]
Get EditMode based on os and mode @return edit mode
[ "Get", "EditMode", "based", "on", "os", "and", "mode" ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/command/settings/SettingsImpl.java#L205-L217
163,228
aeshell/aesh
aesh/src/main/java/org/aesh/command/settings/SettingsImpl.java
SettingsImpl.logFile
@Override public String logFile() { if(logFile == null) { logFile = Config.getTmpDir()+Config.getPathSeparator()+"aesh.log"; } return logFile; }
java
@Override public String logFile() { if(logFile == null) { logFile = Config.getTmpDir()+Config.getPathSeparator()+"aesh.log"; } return logFile; }
[ "@", "Override", "public", "String", "logFile", "(", ")", "{", "if", "(", "logFile", "==", "null", ")", "{", "logFile", "=", "Config", ".", "getTmpDir", "(", ")", "+", "Config", ".", "getPathSeparator", "(", ")", "+", "\"aesh.log\"", ";", "}", "return", "logFile", ";", "}" ]
Get log file @return log file
[ "Get", "log", "file" ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/command/settings/SettingsImpl.java#L414-L420
163,229
aeshell/aesh
aesh/src/main/java/org/aesh/io/scanner/AnnotationDetector.java
AnnotationDetector.detect
public void detect(final String... packageNames) throws IOException { final String[] pkgNameFilter = new String[packageNames.length]; for (int i = 0; i < pkgNameFilter.length; ++i) { pkgNameFilter[i] = packageNames[i].replace('.', '/'); if (!pkgNameFilter[i].endsWith("/")) { pkgNameFilter[i] = pkgNameFilter[i].concat("/"); } } final Set<File> files = new HashSet<>(); final ClassLoader loader = Thread.currentThread().getContextClassLoader(); for (final String packageName : pkgNameFilter) { final Enumeration<URL> resourceEnum = loader.getResources(packageName); while (resourceEnum.hasMoreElements()) { final URL url = resourceEnum.nextElement(); if ("file".equals(url.getProtocol())) { final File dir = toFile(url); if (dir.isDirectory()) { files.add(dir); } else { throw new AssertionError("Not a recognized file URL: " + url); } } else { final File jarFile = toFile(openJarURLConnection(url).getJarFileURL()); if (jarFile.isFile()) { files.add(jarFile); } else { throw new AssertionError("Not a File: " + jarFile); } } } } if (DEBUG) { print("Files to scan: %s", files); } if (!files.isEmpty()) { // see http://shipilev.net/blog/2016/arrays-wisdom-ancients/#_conclusion detect(new ClassFileIterator(files.toArray(new File[0]), pkgNameFilter)); } }
java
public void detect(final String... packageNames) throws IOException { final String[] pkgNameFilter = new String[packageNames.length]; for (int i = 0; i < pkgNameFilter.length; ++i) { pkgNameFilter[i] = packageNames[i].replace('.', '/'); if (!pkgNameFilter[i].endsWith("/")) { pkgNameFilter[i] = pkgNameFilter[i].concat("/"); } } final Set<File> files = new HashSet<>(); final ClassLoader loader = Thread.currentThread().getContextClassLoader(); for (final String packageName : pkgNameFilter) { final Enumeration<URL> resourceEnum = loader.getResources(packageName); while (resourceEnum.hasMoreElements()) { final URL url = resourceEnum.nextElement(); if ("file".equals(url.getProtocol())) { final File dir = toFile(url); if (dir.isDirectory()) { files.add(dir); } else { throw new AssertionError("Not a recognized file URL: " + url); } } else { final File jarFile = toFile(openJarURLConnection(url).getJarFileURL()); if (jarFile.isFile()) { files.add(jarFile); } else { throw new AssertionError("Not a File: " + jarFile); } } } } if (DEBUG) { print("Files to scan: %s", files); } if (!files.isEmpty()) { // see http://shipilev.net/blog/2016/arrays-wisdom-ancients/#_conclusion detect(new ClassFileIterator(files.toArray(new File[0]), pkgNameFilter)); } }
[ "public", "void", "detect", "(", "final", "String", "...", "packageNames", ")", "throws", "IOException", "{", "final", "String", "[", "]", "pkgNameFilter", "=", "new", "String", "[", "packageNames", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pkgNameFilter", ".", "length", ";", "++", "i", ")", "{", "pkgNameFilter", "[", "i", "]", "=", "packageNames", "[", "i", "]", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ";", "if", "(", "!", "pkgNameFilter", "[", "i", "]", ".", "endsWith", "(", "\"/\"", ")", ")", "{", "pkgNameFilter", "[", "i", "]", "=", "pkgNameFilter", "[", "i", "]", ".", "concat", "(", "\"/\"", ")", ";", "}", "}", "final", "Set", "<", "File", ">", "files", "=", "new", "HashSet", "<>", "(", ")", ";", "final", "ClassLoader", "loader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "for", "(", "final", "String", "packageName", ":", "pkgNameFilter", ")", "{", "final", "Enumeration", "<", "URL", ">", "resourceEnum", "=", "loader", ".", "getResources", "(", "packageName", ")", ";", "while", "(", "resourceEnum", ".", "hasMoreElements", "(", ")", ")", "{", "final", "URL", "url", "=", "resourceEnum", ".", "nextElement", "(", ")", ";", "if", "(", "\"file\"", ".", "equals", "(", "url", ".", "getProtocol", "(", ")", ")", ")", "{", "final", "File", "dir", "=", "toFile", "(", "url", ")", ";", "if", "(", "dir", ".", "isDirectory", "(", ")", ")", "{", "files", ".", "add", "(", "dir", ")", ";", "}", "else", "{", "throw", "new", "AssertionError", "(", "\"Not a recognized file URL: \"", "+", "url", ")", ";", "}", "}", "else", "{", "final", "File", "jarFile", "=", "toFile", "(", "openJarURLConnection", "(", "url", ")", ".", "getJarFileURL", "(", ")", ")", ";", "if", "(", "jarFile", ".", "isFile", "(", ")", ")", "{", "files", ".", "add", "(", "jarFile", ")", ";", "}", "else", "{", "throw", "new", "AssertionError", "(", "\"Not a File: \"", "+", "jarFile", ")", ";", "}", "}", "}", "}", "if", "(", "DEBUG", ")", "{", "print", "(", "\"Files to scan: %s\"", ",", "files", ")", ";", "}", "if", "(", "!", "files", ".", "isEmpty", "(", ")", ")", "{", "// see http://shipilev.net/blog/2016/arrays-wisdom-ancients/#_conclusion", "detect", "(", "new", "ClassFileIterator", "(", "files", ".", "toArray", "(", "new", "File", "[", "0", "]", ")", ",", "pkgNameFilter", ")", ")", ";", "}", "}" ]
Report all Java ClassFile files available on the class path within the specified packages and sub packages. @see #detect(File...)
[ "Report", "all", "Java", "ClassFile", "files", "available", "on", "the", "class", "path", "within", "the", "specified", "packages", "and", "sub", "packages", "." ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/io/scanner/AnnotationDetector.java#L243-L281
163,230
aeshell/aesh
aesh/src/main/java/org/aesh/io/scanner/FileIterator.java
FileIterator.addReverse
private void addReverse(final File[] files) { for (int i = files.length - 1; i >= 0; --i) { stack.add(files[i]); } }
java
private void addReverse(final File[] files) { for (int i = files.length - 1; i >= 0; --i) { stack.add(files[i]); } }
[ "private", "void", "addReverse", "(", "final", "File", "[", "]", "files", ")", "{", "for", "(", "int", "i", "=", "files", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "stack", ".", "add", "(", "files", "[", "i", "]", ")", ";", "}", "}" ]
Add the specified files in reverse order.
[ "Add", "the", "specified", "files", "in", "reverse", "order", "." ]
fd7d38d333c5dbf116a9778523a4d1df61f027a3
https://github.com/aeshell/aesh/blob/fd7d38d333c5dbf116a9778523a4d1df61f027a3/aesh/src/main/java/org/aesh/io/scanner/FileIterator.java#L113-L117
163,231
weld/core
impl/src/main/java/org/jboss/weld/serialization/ContextualStoreImpl.java
ContextualStoreImpl.getContextual
public <C extends Contextual<I>, I> C getContextual(String id) { return this.<C, I>getContextual(new StringBeanIdentifier(id)); }
java
public <C extends Contextual<I>, I> C getContextual(String id) { return this.<C, I>getContextual(new StringBeanIdentifier(id)); }
[ "public", "<", "C", "extends", "Contextual", "<", "I", ">", ",", "I", ">", "C", "getContextual", "(", "String", "id", ")", "{", "return", "this", ".", "<", "C", ",", "I", ">", "getContextual", "(", "new", "StringBeanIdentifier", "(", "id", ")", ")", ";", "}" ]
Given a particular id, return the correct contextual. For contextuals which aren't passivation capable, the contextual can't be found in another container, and null will be returned. @param id An identifier for the contextual @return the contextual
[ "Given", "a", "particular", "id", "return", "the", "correct", "contextual", ".", "For", "contextuals", "which", "aren", "t", "passivation", "capable", "the", "contextual", "can", "t", "be", "found", "in", "another", "container", "and", "null", "will", "be", "returned", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/serialization/ContextualStoreImpl.java#L83-L85
163,232
weld/core
modules/web/src/main/java/org/jboss/weld/module/web/servlet/ConversationContextActivator.java
ConversationContextActivator.processDestructionQueue
private void processDestructionQueue(HttpServletRequest request) { Object contextsAttribute = request.getAttribute(DESTRUCTION_QUEUE_ATTRIBUTE_NAME); if (contextsAttribute instanceof Map) { Map<String, List<ContextualInstance<?>>> contexts = cast(contextsAttribute); synchronized (contexts) { FastEvent<String> beforeDestroyedEvent = FastEvent.of(String.class, beanManager, BeforeDestroyed.Literal.CONVERSATION); FastEvent<String> destroyedEvent = FastEvent.of(String.class, beanManager, Destroyed.Literal.CONVERSATION); for (Iterator<Entry<String, List<ContextualInstance<?>>>> iterator = contexts.entrySet().iterator(); iterator.hasNext();) { Entry<String, List<ContextualInstance<?>>> entry = iterator.next(); beforeDestroyedEvent.fire(entry.getKey()); for (ContextualInstance<?> contextualInstance : entry.getValue()) { destroyContextualInstance(contextualInstance); } // Note that for the attached/current conversation we fire the destroyed event twice because we can't reliably identify such a conversation destroyedEvent.fire(entry.getKey()); iterator.remove(); } } } }
java
private void processDestructionQueue(HttpServletRequest request) { Object contextsAttribute = request.getAttribute(DESTRUCTION_QUEUE_ATTRIBUTE_NAME); if (contextsAttribute instanceof Map) { Map<String, List<ContextualInstance<?>>> contexts = cast(contextsAttribute); synchronized (contexts) { FastEvent<String> beforeDestroyedEvent = FastEvent.of(String.class, beanManager, BeforeDestroyed.Literal.CONVERSATION); FastEvent<String> destroyedEvent = FastEvent.of(String.class, beanManager, Destroyed.Literal.CONVERSATION); for (Iterator<Entry<String, List<ContextualInstance<?>>>> iterator = contexts.entrySet().iterator(); iterator.hasNext();) { Entry<String, List<ContextualInstance<?>>> entry = iterator.next(); beforeDestroyedEvent.fire(entry.getKey()); for (ContextualInstance<?> contextualInstance : entry.getValue()) { destroyContextualInstance(contextualInstance); } // Note that for the attached/current conversation we fire the destroyed event twice because we can't reliably identify such a conversation destroyedEvent.fire(entry.getKey()); iterator.remove(); } } } }
[ "private", "void", "processDestructionQueue", "(", "HttpServletRequest", "request", ")", "{", "Object", "contextsAttribute", "=", "request", ".", "getAttribute", "(", "DESTRUCTION_QUEUE_ATTRIBUTE_NAME", ")", ";", "if", "(", "contextsAttribute", "instanceof", "Map", ")", "{", "Map", "<", "String", ",", "List", "<", "ContextualInstance", "<", "?", ">", ">", ">", "contexts", "=", "cast", "(", "contextsAttribute", ")", ";", "synchronized", "(", "contexts", ")", "{", "FastEvent", "<", "String", ">", "beforeDestroyedEvent", "=", "FastEvent", ".", "of", "(", "String", ".", "class", ",", "beanManager", ",", "BeforeDestroyed", ".", "Literal", ".", "CONVERSATION", ")", ";", "FastEvent", "<", "String", ">", "destroyedEvent", "=", "FastEvent", ".", "of", "(", "String", ".", "class", ",", "beanManager", ",", "Destroyed", ".", "Literal", ".", "CONVERSATION", ")", ";", "for", "(", "Iterator", "<", "Entry", "<", "String", ",", "List", "<", "ContextualInstance", "<", "?", ">", ">", ">", ">", "iterator", "=", "contexts", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "Entry", "<", "String", ",", "List", "<", "ContextualInstance", "<", "?", ">", ">", ">", "entry", "=", "iterator", ".", "next", "(", ")", ";", "beforeDestroyedEvent", ".", "fire", "(", "entry", ".", "getKey", "(", ")", ")", ";", "for", "(", "ContextualInstance", "<", "?", ">", "contextualInstance", ":", "entry", ".", "getValue", "(", ")", ")", "{", "destroyContextualInstance", "(", "contextualInstance", ")", ";", "}", "// Note that for the attached/current conversation we fire the destroyed event twice because we can't reliably identify such a conversation", "destroyedEvent", ".", "fire", "(", "entry", ".", "getKey", "(", ")", ")", ";", "iterator", ".", "remove", "(", ")", ";", "}", "}", "}", "}" ]
If needed, destroy the remaining conversation contexts after an HTTP session was invalidated within the current request. @param request
[ "If", "needed", "destroy", "the", "remaining", "conversation", "contexts", "after", "an", "HTTP", "session", "was", "invalidated", "within", "the", "current", "request", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/modules/web/src/main/java/org/jboss/weld/module/web/servlet/ConversationContextActivator.java#L193-L212
163,233
weld/core
modules/ejb/src/main/java/org/jboss/weld/module/ejb/SessionBeanAwareInjectionPointBean.java
SessionBeanAwareInjectionPointBean.unregisterContextualInstance
public static void unregisterContextualInstance(EjbDescriptor<?> descriptor) { Set<Class<?>> classes = CONTEXTUAL_SESSION_BEANS.get(); classes.remove(descriptor.getBeanClass()); if (classes.isEmpty()) { CONTEXTUAL_SESSION_BEANS.remove(); } }
java
public static void unregisterContextualInstance(EjbDescriptor<?> descriptor) { Set<Class<?>> classes = CONTEXTUAL_SESSION_BEANS.get(); classes.remove(descriptor.getBeanClass()); if (classes.isEmpty()) { CONTEXTUAL_SESSION_BEANS.remove(); } }
[ "public", "static", "void", "unregisterContextualInstance", "(", "EjbDescriptor", "<", "?", ">", "descriptor", ")", "{", "Set", "<", "Class", "<", "?", ">", ">", "classes", "=", "CONTEXTUAL_SESSION_BEANS", ".", "get", "(", ")", ";", "classes", ".", "remove", "(", "descriptor", ".", "getBeanClass", "(", ")", ")", ";", "if", "(", "classes", ".", "isEmpty", "(", ")", ")", "{", "CONTEXTUAL_SESSION_BEANS", ".", "remove", "(", ")", ";", "}", "}" ]
Indicates that contextual session bean instance has been constructed.
[ "Indicates", "that", "contextual", "session", "bean", "instance", "has", "been", "constructed", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/modules/ejb/src/main/java/org/jboss/weld/module/ejb/SessionBeanAwareInjectionPointBean.java#L99-L105
163,234
weld/core
impl/src/main/java/org/jboss/weld/injection/StaticMethodInjectionPoint.java
StaticMethodInjectionPoint.getParameterValues
protected Object[] getParameterValues(Object specialVal, BeanManagerImpl manager, CreationalContext<?> ctx, CreationalContext<?> transientReferenceContext) { if (getInjectionPoints().isEmpty()) { if (specialInjectionPointIndex == -1) { return Arrays2.EMPTY_ARRAY; } else { return new Object[] { specialVal }; } } Object[] parameterValues = new Object[getParameterInjectionPoints().size()]; List<ParameterInjectionPoint<?, X>> parameters = getParameterInjectionPoints(); for (int i = 0; i < parameterValues.length; i++) { ParameterInjectionPoint<?, ?> param = parameters.get(i); if (i == specialInjectionPointIndex) { parameterValues[i] = specialVal; } else if (hasTransientReferenceParameter && param.getAnnotated().isAnnotationPresent(TransientReference.class)) { parameterValues[i] = param.getValueToInject(manager, transientReferenceContext); } else { parameterValues[i] = param.getValueToInject(manager, ctx); } } return parameterValues; }
java
protected Object[] getParameterValues(Object specialVal, BeanManagerImpl manager, CreationalContext<?> ctx, CreationalContext<?> transientReferenceContext) { if (getInjectionPoints().isEmpty()) { if (specialInjectionPointIndex == -1) { return Arrays2.EMPTY_ARRAY; } else { return new Object[] { specialVal }; } } Object[] parameterValues = new Object[getParameterInjectionPoints().size()]; List<ParameterInjectionPoint<?, X>> parameters = getParameterInjectionPoints(); for (int i = 0; i < parameterValues.length; i++) { ParameterInjectionPoint<?, ?> param = parameters.get(i); if (i == specialInjectionPointIndex) { parameterValues[i] = specialVal; } else if (hasTransientReferenceParameter && param.getAnnotated().isAnnotationPresent(TransientReference.class)) { parameterValues[i] = param.getValueToInject(manager, transientReferenceContext); } else { parameterValues[i] = param.getValueToInject(manager, ctx); } } return parameterValues; }
[ "protected", "Object", "[", "]", "getParameterValues", "(", "Object", "specialVal", ",", "BeanManagerImpl", "manager", ",", "CreationalContext", "<", "?", ">", "ctx", ",", "CreationalContext", "<", "?", ">", "transientReferenceContext", ")", "{", "if", "(", "getInjectionPoints", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "specialInjectionPointIndex", "==", "-", "1", ")", "{", "return", "Arrays2", ".", "EMPTY_ARRAY", ";", "}", "else", "{", "return", "new", "Object", "[", "]", "{", "specialVal", "}", ";", "}", "}", "Object", "[", "]", "parameterValues", "=", "new", "Object", "[", "getParameterInjectionPoints", "(", ")", ".", "size", "(", ")", "]", ";", "List", "<", "ParameterInjectionPoint", "<", "?", ",", "X", ">", ">", "parameters", "=", "getParameterInjectionPoints", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "parameterValues", ".", "length", ";", "i", "++", ")", "{", "ParameterInjectionPoint", "<", "?", ",", "?", ">", "param", "=", "parameters", ".", "get", "(", "i", ")", ";", "if", "(", "i", "==", "specialInjectionPointIndex", ")", "{", "parameterValues", "[", "i", "]", "=", "specialVal", ";", "}", "else", "if", "(", "hasTransientReferenceParameter", "&&", "param", ".", "getAnnotated", "(", ")", ".", "isAnnotationPresent", "(", "TransientReference", ".", "class", ")", ")", "{", "parameterValues", "[", "i", "]", "=", "param", ".", "getValueToInject", "(", "manager", ",", "transientReferenceContext", ")", ";", "}", "else", "{", "parameterValues", "[", "i", "]", "=", "param", ".", "getValueToInject", "(", "manager", ",", "ctx", ")", ";", "}", "}", "return", "parameterValues", ";", "}" ]
Helper method for getting the current parameter values from a list of annotated parameters. @param parameters The list of annotated parameter to look up @param manager The Bean manager @return The object array of looked up values
[ "Helper", "method", "for", "getting", "the", "current", "parameter", "values", "from", "a", "list", "of", "annotated", "parameters", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/injection/StaticMethodInjectionPoint.java#L117-L138
163,235
weld/core
impl/src/main/java/org/jboss/weld/bootstrap/SpecializationAndEnablementRegistry.java
SpecializationAndEnablementRegistry.resolveSpecializedBeans
public Set<? extends AbstractBean<?, ?>> resolveSpecializedBeans(Bean<?> specializingBean) { if (specializingBean instanceof AbstractClassBean<?>) { AbstractClassBean<?> abstractClassBean = (AbstractClassBean<?>) specializingBean; if (abstractClassBean.isSpecializing()) { return specializedBeans.getValue(specializingBean); } } if (specializingBean instanceof ProducerMethod<?, ?>) { ProducerMethod<?, ?> producerMethod = (ProducerMethod<?, ?>) specializingBean; if (producerMethod.isSpecializing()) { return specializedBeans.getValue(specializingBean); } } return Collections.emptySet(); }
java
public Set<? extends AbstractBean<?, ?>> resolveSpecializedBeans(Bean<?> specializingBean) { if (specializingBean instanceof AbstractClassBean<?>) { AbstractClassBean<?> abstractClassBean = (AbstractClassBean<?>) specializingBean; if (abstractClassBean.isSpecializing()) { return specializedBeans.getValue(specializingBean); } } if (specializingBean instanceof ProducerMethod<?, ?>) { ProducerMethod<?, ?> producerMethod = (ProducerMethod<?, ?>) specializingBean; if (producerMethod.isSpecializing()) { return specializedBeans.getValue(specializingBean); } } return Collections.emptySet(); }
[ "public", "Set", "<", "?", "extends", "AbstractBean", "<", "?", ",", "?", ">", ">", "resolveSpecializedBeans", "(", "Bean", "<", "?", ">", "specializingBean", ")", "{", "if", "(", "specializingBean", "instanceof", "AbstractClassBean", "<", "?", ">", ")", "{", "AbstractClassBean", "<", "?", ">", "abstractClassBean", "=", "(", "AbstractClassBean", "<", "?", ">", ")", "specializingBean", ";", "if", "(", "abstractClassBean", ".", "isSpecializing", "(", ")", ")", "{", "return", "specializedBeans", ".", "getValue", "(", "specializingBean", ")", ";", "}", "}", "if", "(", "specializingBean", "instanceof", "ProducerMethod", "<", "?", ",", "?", ">", ")", "{", "ProducerMethod", "<", "?", ",", "?", ">", "producerMethod", "=", "(", "ProducerMethod", "<", "?", ",", "?", ">", ")", "specializingBean", ";", "if", "(", "producerMethod", ".", "isSpecializing", "(", ")", ")", "{", "return", "specializedBeans", ".", "getValue", "(", "specializingBean", ")", ";", "}", "}", "return", "Collections", ".", "emptySet", "(", ")", ";", "}" ]
Returns a set of beans specialized by this bean. An empty set is returned if this bean does not specialize another beans.
[ "Returns", "a", "set", "of", "beans", "specialized", "by", "this", "bean", ".", "An", "empty", "set", "is", "returned", "if", "this", "bean", "does", "not", "specialize", "another", "beans", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bootstrap/SpecializationAndEnablementRegistry.java#L129-L143
163,236
weld/core
impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyFactory.java
DecoratorProxyFactory.addHandlerInitializerMethod
private void addHandlerInitializerMethod(ClassFile proxyClassType, ClassMethod staticConstructor) throws Exception { ClassMethod classMethod = proxyClassType.addMethod(AccessFlag.PRIVATE, INIT_MH_METHOD_NAME, BytecodeUtils.VOID_CLASS_DESCRIPTOR, LJAVA_LANG_OBJECT); final CodeAttribute b = classMethod.getCodeAttribute(); b.aload(0); StaticMethodInformation methodInfo = new StaticMethodInformation(INIT_MH_METHOD_NAME, new Class[] { Object.class }, void.class, classMethod.getClassFile().getName()); invokeMethodHandler(classMethod, methodInfo, false, DEFAULT_METHOD_RESOLVER, staticConstructor); b.checkcast(MethodHandler.class); b.putfield(classMethod.getClassFile().getName(), METHOD_HANDLER_FIELD_NAME, DescriptorUtils.makeDescriptor(MethodHandler.class)); b.returnInstruction(); BeanLogger.LOG.createdMethodHandlerInitializerForDecoratorProxy(getBeanType()); }
java
private void addHandlerInitializerMethod(ClassFile proxyClassType, ClassMethod staticConstructor) throws Exception { ClassMethod classMethod = proxyClassType.addMethod(AccessFlag.PRIVATE, INIT_MH_METHOD_NAME, BytecodeUtils.VOID_CLASS_DESCRIPTOR, LJAVA_LANG_OBJECT); final CodeAttribute b = classMethod.getCodeAttribute(); b.aload(0); StaticMethodInformation methodInfo = new StaticMethodInformation(INIT_MH_METHOD_NAME, new Class[] { Object.class }, void.class, classMethod.getClassFile().getName()); invokeMethodHandler(classMethod, methodInfo, false, DEFAULT_METHOD_RESOLVER, staticConstructor); b.checkcast(MethodHandler.class); b.putfield(classMethod.getClassFile().getName(), METHOD_HANDLER_FIELD_NAME, DescriptorUtils.makeDescriptor(MethodHandler.class)); b.returnInstruction(); BeanLogger.LOG.createdMethodHandlerInitializerForDecoratorProxy(getBeanType()); }
[ "private", "void", "addHandlerInitializerMethod", "(", "ClassFile", "proxyClassType", ",", "ClassMethod", "staticConstructor", ")", "throws", "Exception", "{", "ClassMethod", "classMethod", "=", "proxyClassType", ".", "addMethod", "(", "AccessFlag", ".", "PRIVATE", ",", "INIT_MH_METHOD_NAME", ",", "BytecodeUtils", ".", "VOID_CLASS_DESCRIPTOR", ",", "LJAVA_LANG_OBJECT", ")", ";", "final", "CodeAttribute", "b", "=", "classMethod", ".", "getCodeAttribute", "(", ")", ";", "b", ".", "aload", "(", "0", ")", ";", "StaticMethodInformation", "methodInfo", "=", "new", "StaticMethodInformation", "(", "INIT_MH_METHOD_NAME", ",", "new", "Class", "[", "]", "{", "Object", ".", "class", "}", ",", "void", ".", "class", ",", "classMethod", ".", "getClassFile", "(", ")", ".", "getName", "(", ")", ")", ";", "invokeMethodHandler", "(", "classMethod", ",", "methodInfo", ",", "false", ",", "DEFAULT_METHOD_RESOLVER", ",", "staticConstructor", ")", ";", "b", ".", "checkcast", "(", "MethodHandler", ".", "class", ")", ";", "b", ".", "putfield", "(", "classMethod", ".", "getClassFile", "(", ")", ".", "getName", "(", ")", ",", "METHOD_HANDLER_FIELD_NAME", ",", "DescriptorUtils", ".", "makeDescriptor", "(", "MethodHandler", ".", "class", ")", ")", ";", "b", ".", "returnInstruction", "(", ")", ";", "BeanLogger", ".", "LOG", ".", "createdMethodHandlerInitializerForDecoratorProxy", "(", "getBeanType", "(", ")", ")", ";", "}" ]
calls _initMH on the method handler and then stores the result in the methodHandler field as then new methodHandler
[ "calls", "_initMH", "on", "the", "method", "handler", "and", "then", "stores", "the", "result", "in", "the", "methodHandler", "field", "as", "then", "new", "methodHandler" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyFactory.java#L81-L93
163,237
weld/core
impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyFactory.java
DecoratorProxyFactory.isEqual
private static boolean isEqual(Method m, Method a) { if (m.getName().equals(a.getName()) && m.getParameterTypes().length == a.getParameterTypes().length && m.getReturnType().isAssignableFrom(a.getReturnType())) { for (int i = 0; i < m.getParameterTypes().length; i++) { if (!(m.getParameterTypes()[i].isAssignableFrom(a.getParameterTypes()[i]))) { return false; } } return true; } return false; }
java
private static boolean isEqual(Method m, Method a) { if (m.getName().equals(a.getName()) && m.getParameterTypes().length == a.getParameterTypes().length && m.getReturnType().isAssignableFrom(a.getReturnType())) { for (int i = 0; i < m.getParameterTypes().length; i++) { if (!(m.getParameterTypes()[i].isAssignableFrom(a.getParameterTypes()[i]))) { return false; } } return true; } return false; }
[ "private", "static", "boolean", "isEqual", "(", "Method", "m", ",", "Method", "a", ")", "{", "if", "(", "m", ".", "getName", "(", ")", ".", "equals", "(", "a", ".", "getName", "(", ")", ")", "&&", "m", ".", "getParameterTypes", "(", ")", ".", "length", "==", "a", ".", "getParameterTypes", "(", ")", ".", "length", "&&", "m", ".", "getReturnType", "(", ")", ".", "isAssignableFrom", "(", "a", ".", "getReturnType", "(", ")", ")", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "m", ".", "getParameterTypes", "(", ")", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "(", "m", ".", "getParameterTypes", "(", ")", "[", "i", "]", ".", "isAssignableFrom", "(", "a", ".", "getParameterTypes", "(", ")", "[", "i", "]", ")", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
m is more generic than a
[ "m", "is", "more", "generic", "than", "a" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyFactory.java#L163-L173
163,238
weld/core
environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/WeldServletLifecycle.java
WeldServletLifecycle.createDeployment
protected CDI11Deployment createDeployment(ServletContext context, CDI11Bootstrap bootstrap) { ImmutableSet.Builder<Metadata<Extension>> extensionsBuilder = ImmutableSet.builder(); extensionsBuilder.addAll(bootstrap.loadExtensions(WeldResourceLoader.getClassLoader())); if (isDevModeEnabled) { extensionsBuilder.add(new MetadataImpl<Extension>(DevelopmentMode.getProbeExtension(resourceLoader), "N/A")); } final Iterable<Metadata<Extension>> extensions = extensionsBuilder.build(); final TypeDiscoveryConfiguration typeDiscoveryConfiguration = bootstrap.startExtensions(extensions); final EEModuleDescriptor eeModule = new EEModuleDescriptorImpl(context.getContextPath(), ModuleType.WEB); final DiscoveryStrategy strategy = DiscoveryStrategyFactory.create(resourceLoader, bootstrap, typeDiscoveryConfiguration.getKnownBeanDefiningAnnotations(), Boolean.parseBoolean(context.getInitParameter(Jandex.DISABLE_JANDEX_DISCOVERY_STRATEGY))); if (Jandex.isJandexAvailable(resourceLoader)) { try { Class<? extends BeanArchiveHandler> handlerClass = Reflections.loadClass(resourceLoader, JANDEX_SERVLET_CONTEXT_BEAN_ARCHIVE_HANDLER); strategy.registerHandler((SecurityActions.newConstructorInstance(handlerClass, new Class<?>[] { ServletContext.class }, context))); } catch (Exception e) { throw CommonLogger.LOG.unableToInstantiate(JANDEX_SERVLET_CONTEXT_BEAN_ARCHIVE_HANDLER, Arrays.toString(new Object[] { context }), e); } } else { strategy.registerHandler(new ServletContextBeanArchiveHandler(context)); } strategy.setScanner(new WebAppBeanArchiveScanner(resourceLoader, bootstrap, context)); Set<WeldBeanDeploymentArchive> beanDeploymentArchives = strategy.performDiscovery(); String isolation = context.getInitParameter(CONTEXT_PARAM_ARCHIVE_ISOLATION); if (isolation == null || Boolean.valueOf(isolation)) { CommonLogger.LOG.archiveIsolationEnabled(); } else { CommonLogger.LOG.archiveIsolationDisabled(); Set<WeldBeanDeploymentArchive> flatDeployment = new HashSet<WeldBeanDeploymentArchive>(); flatDeployment.add(WeldBeanDeploymentArchive.merge(bootstrap, beanDeploymentArchives)); beanDeploymentArchives = flatDeployment; } for (BeanDeploymentArchive archive : beanDeploymentArchives) { archive.getServices().add(EEModuleDescriptor.class, eeModule); } CDI11Deployment deployment = new WeldDeployment(resourceLoader, bootstrap, beanDeploymentArchives, extensions) { @Override protected WeldBeanDeploymentArchive createAdditionalBeanDeploymentArchive() { WeldBeanDeploymentArchive archive = super.createAdditionalBeanDeploymentArchive(); archive.getServices().add(EEModuleDescriptor.class, eeModule); return archive; } }; if (strategy.getClassFileServices() != null) { deployment.getServices().add(ClassFileServices.class, strategy.getClassFileServices()); } return deployment; }
java
protected CDI11Deployment createDeployment(ServletContext context, CDI11Bootstrap bootstrap) { ImmutableSet.Builder<Metadata<Extension>> extensionsBuilder = ImmutableSet.builder(); extensionsBuilder.addAll(bootstrap.loadExtensions(WeldResourceLoader.getClassLoader())); if (isDevModeEnabled) { extensionsBuilder.add(new MetadataImpl<Extension>(DevelopmentMode.getProbeExtension(resourceLoader), "N/A")); } final Iterable<Metadata<Extension>> extensions = extensionsBuilder.build(); final TypeDiscoveryConfiguration typeDiscoveryConfiguration = bootstrap.startExtensions(extensions); final EEModuleDescriptor eeModule = new EEModuleDescriptorImpl(context.getContextPath(), ModuleType.WEB); final DiscoveryStrategy strategy = DiscoveryStrategyFactory.create(resourceLoader, bootstrap, typeDiscoveryConfiguration.getKnownBeanDefiningAnnotations(), Boolean.parseBoolean(context.getInitParameter(Jandex.DISABLE_JANDEX_DISCOVERY_STRATEGY))); if (Jandex.isJandexAvailable(resourceLoader)) { try { Class<? extends BeanArchiveHandler> handlerClass = Reflections.loadClass(resourceLoader, JANDEX_SERVLET_CONTEXT_BEAN_ARCHIVE_HANDLER); strategy.registerHandler((SecurityActions.newConstructorInstance(handlerClass, new Class<?>[] { ServletContext.class }, context))); } catch (Exception e) { throw CommonLogger.LOG.unableToInstantiate(JANDEX_SERVLET_CONTEXT_BEAN_ARCHIVE_HANDLER, Arrays.toString(new Object[] { context }), e); } } else { strategy.registerHandler(new ServletContextBeanArchiveHandler(context)); } strategy.setScanner(new WebAppBeanArchiveScanner(resourceLoader, bootstrap, context)); Set<WeldBeanDeploymentArchive> beanDeploymentArchives = strategy.performDiscovery(); String isolation = context.getInitParameter(CONTEXT_PARAM_ARCHIVE_ISOLATION); if (isolation == null || Boolean.valueOf(isolation)) { CommonLogger.LOG.archiveIsolationEnabled(); } else { CommonLogger.LOG.archiveIsolationDisabled(); Set<WeldBeanDeploymentArchive> flatDeployment = new HashSet<WeldBeanDeploymentArchive>(); flatDeployment.add(WeldBeanDeploymentArchive.merge(bootstrap, beanDeploymentArchives)); beanDeploymentArchives = flatDeployment; } for (BeanDeploymentArchive archive : beanDeploymentArchives) { archive.getServices().add(EEModuleDescriptor.class, eeModule); } CDI11Deployment deployment = new WeldDeployment(resourceLoader, bootstrap, beanDeploymentArchives, extensions) { @Override protected WeldBeanDeploymentArchive createAdditionalBeanDeploymentArchive() { WeldBeanDeploymentArchive archive = super.createAdditionalBeanDeploymentArchive(); archive.getServices().add(EEModuleDescriptor.class, eeModule); return archive; } }; if (strategy.getClassFileServices() != null) { deployment.getServices().add(ClassFileServices.class, strategy.getClassFileServices()); } return deployment; }
[ "protected", "CDI11Deployment", "createDeployment", "(", "ServletContext", "context", ",", "CDI11Bootstrap", "bootstrap", ")", "{", "ImmutableSet", ".", "Builder", "<", "Metadata", "<", "Extension", ">>", "extensionsBuilder", "=", "ImmutableSet", ".", "builder", "(", ")", ";", "extensionsBuilder", ".", "addAll", "(", "bootstrap", ".", "loadExtensions", "(", "WeldResourceLoader", ".", "getClassLoader", "(", ")", ")", ")", ";", "if", "(", "isDevModeEnabled", ")", "{", "extensionsBuilder", ".", "add", "(", "new", "MetadataImpl", "<", "Extension", ">", "(", "DevelopmentMode", ".", "getProbeExtension", "(", "resourceLoader", ")", ",", "\"N/A\"", ")", ")", ";", "}", "final", "Iterable", "<", "Metadata", "<", "Extension", ">", ">", "extensions", "=", "extensionsBuilder", ".", "build", "(", ")", ";", "final", "TypeDiscoveryConfiguration", "typeDiscoveryConfiguration", "=", "bootstrap", ".", "startExtensions", "(", "extensions", ")", ";", "final", "EEModuleDescriptor", "eeModule", "=", "new", "EEModuleDescriptorImpl", "(", "context", ".", "getContextPath", "(", ")", ",", "ModuleType", ".", "WEB", ")", ";", "final", "DiscoveryStrategy", "strategy", "=", "DiscoveryStrategyFactory", ".", "create", "(", "resourceLoader", ",", "bootstrap", ",", "typeDiscoveryConfiguration", ".", "getKnownBeanDefiningAnnotations", "(", ")", ",", "Boolean", ".", "parseBoolean", "(", "context", ".", "getInitParameter", "(", "Jandex", ".", "DISABLE_JANDEX_DISCOVERY_STRATEGY", ")", ")", ")", ";", "if", "(", "Jandex", ".", "isJandexAvailable", "(", "resourceLoader", ")", ")", "{", "try", "{", "Class", "<", "?", "extends", "BeanArchiveHandler", ">", "handlerClass", "=", "Reflections", ".", "loadClass", "(", "resourceLoader", ",", "JANDEX_SERVLET_CONTEXT_BEAN_ARCHIVE_HANDLER", ")", ";", "strategy", ".", "registerHandler", "(", "(", "SecurityActions", ".", "newConstructorInstance", "(", "handlerClass", ",", "new", "Class", "<", "?", ">", "[", "]", "{", "ServletContext", ".", "class", "}", ",", "context", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "CommonLogger", ".", "LOG", ".", "unableToInstantiate", "(", "JANDEX_SERVLET_CONTEXT_BEAN_ARCHIVE_HANDLER", ",", "Arrays", ".", "toString", "(", "new", "Object", "[", "]", "{", "context", "}", ")", ",", "e", ")", ";", "}", "}", "else", "{", "strategy", ".", "registerHandler", "(", "new", "ServletContextBeanArchiveHandler", "(", "context", ")", ")", ";", "}", "strategy", ".", "setScanner", "(", "new", "WebAppBeanArchiveScanner", "(", "resourceLoader", ",", "bootstrap", ",", "context", ")", ")", ";", "Set", "<", "WeldBeanDeploymentArchive", ">", "beanDeploymentArchives", "=", "strategy", ".", "performDiscovery", "(", ")", ";", "String", "isolation", "=", "context", ".", "getInitParameter", "(", "CONTEXT_PARAM_ARCHIVE_ISOLATION", ")", ";", "if", "(", "isolation", "==", "null", "||", "Boolean", ".", "valueOf", "(", "isolation", ")", ")", "{", "CommonLogger", ".", "LOG", ".", "archiveIsolationEnabled", "(", ")", ";", "}", "else", "{", "CommonLogger", ".", "LOG", ".", "archiveIsolationDisabled", "(", ")", ";", "Set", "<", "WeldBeanDeploymentArchive", ">", "flatDeployment", "=", "new", "HashSet", "<", "WeldBeanDeploymentArchive", ">", "(", ")", ";", "flatDeployment", ".", "add", "(", "WeldBeanDeploymentArchive", ".", "merge", "(", "bootstrap", ",", "beanDeploymentArchives", ")", ")", ";", "beanDeploymentArchives", "=", "flatDeployment", ";", "}", "for", "(", "BeanDeploymentArchive", "archive", ":", "beanDeploymentArchives", ")", "{", "archive", ".", "getServices", "(", ")", ".", "add", "(", "EEModuleDescriptor", ".", "class", ",", "eeModule", ")", ";", "}", "CDI11Deployment", "deployment", "=", "new", "WeldDeployment", "(", "resourceLoader", ",", "bootstrap", ",", "beanDeploymentArchives", ",", "extensions", ")", "{", "@", "Override", "protected", "WeldBeanDeploymentArchive", "createAdditionalBeanDeploymentArchive", "(", ")", "{", "WeldBeanDeploymentArchive", "archive", "=", "super", ".", "createAdditionalBeanDeploymentArchive", "(", ")", ";", "archive", ".", "getServices", "(", ")", ".", "add", "(", "EEModuleDescriptor", ".", "class", ",", "eeModule", ")", ";", "return", "archive", ";", "}", "}", ";", "if", "(", "strategy", ".", "getClassFileServices", "(", ")", "!=", "null", ")", "{", "deployment", ".", "getServices", "(", ")", ".", "add", "(", "ClassFileServices", ".", "class", ",", "strategy", ".", "getClassFileServices", "(", ")", ")", ";", "}", "return", "deployment", ";", "}" ]
Create servlet deployment. Can be overridden with custom servlet deployment. e.g. exact resources listing in restricted env like GAE @param context the servlet context @param bootstrap the bootstrap @return new servlet deployment
[ "Create", "servlet", "deployment", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/WeldServletLifecycle.java#L276-L332
163,239
weld/core
environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/WeldServletLifecycle.java
WeldServletLifecycle.findContainer
protected Container findContainer(ContainerContext ctx, StringBuilder dump) { Container container = null; // 1. Custom container class String containerClassName = ctx.getServletContext().getInitParameter(Container.CONTEXT_PARAM_CONTAINER_CLASS); if (containerClassName != null) { try { Class<Container> containerClass = Reflections.classForName(resourceLoader, containerClassName); container = SecurityActions.newInstance(containerClass); WeldServletLogger.LOG.containerDetectionSkipped(containerClassName); } catch (Exception e) { WeldServletLogger.LOG.unableToInstantiateCustomContainerClass(containerClassName); WeldServletLogger.LOG.catchingDebug(e); } } if (container == null) { // 2. Service providers Iterable<Container> extContainers = ServiceLoader.load(Container.class, getClass().getClassLoader()); container = checkContainers(ctx, dump, extContainers); if (container == null) { // 3. Built-in containers in predefined order container = checkContainers(ctx, dump, Arrays.asList(TomcatContainer.INSTANCE, JettyContainer.INSTANCE, UndertowContainer.INSTANCE, GwtDevHostedModeContainer.INSTANCE)); } } return container; }
java
protected Container findContainer(ContainerContext ctx, StringBuilder dump) { Container container = null; // 1. Custom container class String containerClassName = ctx.getServletContext().getInitParameter(Container.CONTEXT_PARAM_CONTAINER_CLASS); if (containerClassName != null) { try { Class<Container> containerClass = Reflections.classForName(resourceLoader, containerClassName); container = SecurityActions.newInstance(containerClass); WeldServletLogger.LOG.containerDetectionSkipped(containerClassName); } catch (Exception e) { WeldServletLogger.LOG.unableToInstantiateCustomContainerClass(containerClassName); WeldServletLogger.LOG.catchingDebug(e); } } if (container == null) { // 2. Service providers Iterable<Container> extContainers = ServiceLoader.load(Container.class, getClass().getClassLoader()); container = checkContainers(ctx, dump, extContainers); if (container == null) { // 3. Built-in containers in predefined order container = checkContainers(ctx, dump, Arrays.asList(TomcatContainer.INSTANCE, JettyContainer.INSTANCE, UndertowContainer.INSTANCE, GwtDevHostedModeContainer.INSTANCE)); } } return container; }
[ "protected", "Container", "findContainer", "(", "ContainerContext", "ctx", ",", "StringBuilder", "dump", ")", "{", "Container", "container", "=", "null", ";", "// 1. Custom container class", "String", "containerClassName", "=", "ctx", ".", "getServletContext", "(", ")", ".", "getInitParameter", "(", "Container", ".", "CONTEXT_PARAM_CONTAINER_CLASS", ")", ";", "if", "(", "containerClassName", "!=", "null", ")", "{", "try", "{", "Class", "<", "Container", ">", "containerClass", "=", "Reflections", ".", "classForName", "(", "resourceLoader", ",", "containerClassName", ")", ";", "container", "=", "SecurityActions", ".", "newInstance", "(", "containerClass", ")", ";", "WeldServletLogger", ".", "LOG", ".", "containerDetectionSkipped", "(", "containerClassName", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "WeldServletLogger", ".", "LOG", ".", "unableToInstantiateCustomContainerClass", "(", "containerClassName", ")", ";", "WeldServletLogger", ".", "LOG", ".", "catchingDebug", "(", "e", ")", ";", "}", "}", "if", "(", "container", "==", "null", ")", "{", "// 2. Service providers", "Iterable", "<", "Container", ">", "extContainers", "=", "ServiceLoader", ".", "load", "(", "Container", ".", "class", ",", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ";", "container", "=", "checkContainers", "(", "ctx", ",", "dump", ",", "extContainers", ")", ";", "if", "(", "container", "==", "null", ")", "{", "// 3. Built-in containers in predefined order", "container", "=", "checkContainers", "(", "ctx", ",", "dump", ",", "Arrays", ".", "asList", "(", "TomcatContainer", ".", "INSTANCE", ",", "JettyContainer", ".", "INSTANCE", ",", "UndertowContainer", ".", "INSTANCE", ",", "GwtDevHostedModeContainer", ".", "INSTANCE", ")", ")", ";", "}", "}", "return", "container", ";", "}" ]
Find container env. @param ctx the container context @param dump the exception dump @return valid container or null
[ "Find", "container", "env", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/WeldServletLifecycle.java#L341-L366
163,240
weld/core
impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java
ResolvableBuilder.createMetadataProvider
private Resolvable createMetadataProvider(Class<?> rawType) { Set<Type> types = Collections.<Type>singleton(rawType); return new ResolvableImpl(rawType, types, declaringBean, qualifierInstances, delegate); }
java
private Resolvable createMetadataProvider(Class<?> rawType) { Set<Type> types = Collections.<Type>singleton(rawType); return new ResolvableImpl(rawType, types, declaringBean, qualifierInstances, delegate); }
[ "private", "Resolvable", "createMetadataProvider", "(", "Class", "<", "?", ">", "rawType", ")", "{", "Set", "<", "Type", ">", "types", "=", "Collections", ".", "<", "Type", ">", "singleton", "(", "rawType", ")", ";", "return", "new", "ResolvableImpl", "(", "rawType", ",", "types", ",", "declaringBean", ",", "qualifierInstances", ",", "delegate", ")", ";", "}" ]
just as facade but we keep the qualifiers so that we can recognize Bean from @Intercepted Bean.
[ "just", "as", "facade", "but", "we", "keep", "the", "qualifiers", "so", "that", "we", "can", "recognize", "Bean", "from" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/resolution/ResolvableBuilder.java#L143-L146
163,241
weld/core
impl/src/main/java/org/jboss/weld/bean/proxy/InterceptedSubclassFactory.java
InterceptedSubclassFactory.hasAbstractPackagePrivateSuperClassWithImplementation
private boolean hasAbstractPackagePrivateSuperClassWithImplementation(Class<?> clazz, BridgeMethod bridgeMethod) { Class<?> superClass = clazz.getSuperclass(); while (superClass != null) { if (Modifier.isAbstract(superClass.getModifiers()) && Reflections.isPackagePrivate(superClass.getModifiers())) { // if superclass is abstract, we need to dig deeper for (Method method : superClass.getDeclaredMethods()) { if (bridgeMethod.signature.matches(method) && method.getGenericReturnType().equals(bridgeMethod.returnType) && !Reflections.isAbstract(method)) { // this is the case we are after -> methods have same signature and the one in super class has actual implementation return true; } } } superClass = superClass.getSuperclass(); } return false; }
java
private boolean hasAbstractPackagePrivateSuperClassWithImplementation(Class<?> clazz, BridgeMethod bridgeMethod) { Class<?> superClass = clazz.getSuperclass(); while (superClass != null) { if (Modifier.isAbstract(superClass.getModifiers()) && Reflections.isPackagePrivate(superClass.getModifiers())) { // if superclass is abstract, we need to dig deeper for (Method method : superClass.getDeclaredMethods()) { if (bridgeMethod.signature.matches(method) && method.getGenericReturnType().equals(bridgeMethod.returnType) && !Reflections.isAbstract(method)) { // this is the case we are after -> methods have same signature and the one in super class has actual implementation return true; } } } superClass = superClass.getSuperclass(); } return false; }
[ "private", "boolean", "hasAbstractPackagePrivateSuperClassWithImplementation", "(", "Class", "<", "?", ">", "clazz", ",", "BridgeMethod", "bridgeMethod", ")", "{", "Class", "<", "?", ">", "superClass", "=", "clazz", ".", "getSuperclass", "(", ")", ";", "while", "(", "superClass", "!=", "null", ")", "{", "if", "(", "Modifier", ".", "isAbstract", "(", "superClass", ".", "getModifiers", "(", ")", ")", "&&", "Reflections", ".", "isPackagePrivate", "(", "superClass", ".", "getModifiers", "(", ")", ")", ")", "{", "// if superclass is abstract, we need to dig deeper", "for", "(", "Method", "method", ":", "superClass", ".", "getDeclaredMethods", "(", ")", ")", "{", "if", "(", "bridgeMethod", ".", "signature", ".", "matches", "(", "method", ")", "&&", "method", ".", "getGenericReturnType", "(", ")", ".", "equals", "(", "bridgeMethod", ".", "returnType", ")", "&&", "!", "Reflections", ".", "isAbstract", "(", "method", ")", ")", "{", "// this is the case we are after -> methods have same signature and the one in super class has actual implementation", "return", "true", ";", "}", "}", "}", "superClass", "=", "superClass", ".", "getSuperclass", "(", ")", ";", "}", "return", "false", ";", "}" ]
Returns true if super class of the parameter exists and is abstract and package private. In such case we want to omit such method. See WELD-2507 and Oracle issue - https://bugs.java.com/view_bug.do?bug_id=6342411 @return true if the super class exists and is abstract and package private
[ "Returns", "true", "if", "super", "class", "of", "the", "parameter", "exists", "and", "is", "abstract", "and", "package", "private", ".", "In", "such", "case", "we", "want", "to", "omit", "such", "method", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bean/proxy/InterceptedSubclassFactory.java#L273-L289
163,242
weld/core
impl/src/main/java/org/jboss/weld/bean/proxy/InterceptedSubclassFactory.java
InterceptedSubclassFactory.addSpecialMethods
protected void addSpecialMethods(ClassFile proxyClassType, ClassMethod staticConstructor) { try { // Add special methods for interceptors for (Method method : LifecycleMixin.class.getMethods()) { BeanLogger.LOG.addingMethodToProxy(method); MethodInformation methodInfo = new RuntimeMethodInformation(method); createInterceptorBody(proxyClassType.addMethod(method), methodInfo, false, staticConstructor); } Method getInstanceMethod = TargetInstanceProxy.class.getMethod("weld_getTargetInstance"); Method getInstanceClassMethod = TargetInstanceProxy.class.getMethod("weld_getTargetClass"); generateGetTargetInstanceBody(proxyClassType.addMethod(getInstanceMethod)); generateGetTargetClassBody(proxyClassType.addMethod(getInstanceClassMethod)); Method setMethodHandlerMethod = ProxyObject.class.getMethod("weld_setHandler", MethodHandler.class); generateSetMethodHandlerBody(proxyClassType.addMethod(setMethodHandlerMethod)); Method getMethodHandlerMethod = ProxyObject.class.getMethod("weld_getHandler"); generateGetMethodHandlerBody(proxyClassType.addMethod(getMethodHandlerMethod)); } catch (Exception e) { throw new WeldException(e); } }
java
protected void addSpecialMethods(ClassFile proxyClassType, ClassMethod staticConstructor) { try { // Add special methods for interceptors for (Method method : LifecycleMixin.class.getMethods()) { BeanLogger.LOG.addingMethodToProxy(method); MethodInformation methodInfo = new RuntimeMethodInformation(method); createInterceptorBody(proxyClassType.addMethod(method), methodInfo, false, staticConstructor); } Method getInstanceMethod = TargetInstanceProxy.class.getMethod("weld_getTargetInstance"); Method getInstanceClassMethod = TargetInstanceProxy.class.getMethod("weld_getTargetClass"); generateGetTargetInstanceBody(proxyClassType.addMethod(getInstanceMethod)); generateGetTargetClassBody(proxyClassType.addMethod(getInstanceClassMethod)); Method setMethodHandlerMethod = ProxyObject.class.getMethod("weld_setHandler", MethodHandler.class); generateSetMethodHandlerBody(proxyClassType.addMethod(setMethodHandlerMethod)); Method getMethodHandlerMethod = ProxyObject.class.getMethod("weld_getHandler"); generateGetMethodHandlerBody(proxyClassType.addMethod(getMethodHandlerMethod)); } catch (Exception e) { throw new WeldException(e); } }
[ "protected", "void", "addSpecialMethods", "(", "ClassFile", "proxyClassType", ",", "ClassMethod", "staticConstructor", ")", "{", "try", "{", "// Add special methods for interceptors", "for", "(", "Method", "method", ":", "LifecycleMixin", ".", "class", ".", "getMethods", "(", ")", ")", "{", "BeanLogger", ".", "LOG", ".", "addingMethodToProxy", "(", "method", ")", ";", "MethodInformation", "methodInfo", "=", "new", "RuntimeMethodInformation", "(", "method", ")", ";", "createInterceptorBody", "(", "proxyClassType", ".", "addMethod", "(", "method", ")", ",", "methodInfo", ",", "false", ",", "staticConstructor", ")", ";", "}", "Method", "getInstanceMethod", "=", "TargetInstanceProxy", ".", "class", ".", "getMethod", "(", "\"weld_getTargetInstance\"", ")", ";", "Method", "getInstanceClassMethod", "=", "TargetInstanceProxy", ".", "class", ".", "getMethod", "(", "\"weld_getTargetClass\"", ")", ";", "generateGetTargetInstanceBody", "(", "proxyClassType", ".", "addMethod", "(", "getInstanceMethod", ")", ")", ";", "generateGetTargetClassBody", "(", "proxyClassType", ".", "addMethod", "(", "getInstanceClassMethod", ")", ")", ";", "Method", "setMethodHandlerMethod", "=", "ProxyObject", ".", "class", ".", "getMethod", "(", "\"weld_setHandler\"", ",", "MethodHandler", ".", "class", ")", ";", "generateSetMethodHandlerBody", "(", "proxyClassType", ".", "addMethod", "(", "setMethodHandlerMethod", ")", ")", ";", "Method", "getMethodHandlerMethod", "=", "ProxyObject", ".", "class", ".", "getMethod", "(", "\"weld_getHandler\"", ")", ";", "generateGetMethodHandlerBody", "(", "proxyClassType", ".", "addMethod", "(", "getMethodHandlerMethod", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "WeldException", "(", "e", ")", ";", "}", "}" ]
Adds methods requiring special implementations rather than just delegation. @param proxyClassType the Javassist class description for the proxy type
[ "Adds", "methods", "requiring", "special", "implementations", "rather", "than", "just", "delegation", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bean/proxy/InterceptedSubclassFactory.java#L472-L493
163,243
weld/core
impl/src/main/java/org/jboss/weld/util/Decorators.java
Decorators.checkDelegateType
public static void checkDelegateType(Decorator<?> decorator) { Set<Type> types = new HierarchyDiscovery(decorator.getDelegateType()).getTypeClosure(); for (Type decoratedType : decorator.getDecoratedTypes()) { if(!types.contains(decoratedType)) { throw BeanLogger.LOG.delegateMustSupportEveryDecoratedType(decoratedType, decorator); } } }
java
public static void checkDelegateType(Decorator<?> decorator) { Set<Type> types = new HierarchyDiscovery(decorator.getDelegateType()).getTypeClosure(); for (Type decoratedType : decorator.getDecoratedTypes()) { if(!types.contains(decoratedType)) { throw BeanLogger.LOG.delegateMustSupportEveryDecoratedType(decoratedType, decorator); } } }
[ "public", "static", "void", "checkDelegateType", "(", "Decorator", "<", "?", ">", "decorator", ")", "{", "Set", "<", "Type", ">", "types", "=", "new", "HierarchyDiscovery", "(", "decorator", ".", "getDelegateType", "(", ")", ")", ".", "getTypeClosure", "(", ")", ";", "for", "(", "Type", "decoratedType", ":", "decorator", ".", "getDecoratedTypes", "(", ")", ")", "{", "if", "(", "!", "types", ".", "contains", "(", "decoratedType", ")", ")", "{", "throw", "BeanLogger", ".", "LOG", ".", "delegateMustSupportEveryDecoratedType", "(", "decoratedType", ",", "decorator", ")", ";", "}", "}", "}" ]
Check whether the delegate type implements or extends all decorated types. @param decorator @throws DefinitionException If the delegate type doesn't implement or extend all decorated types
[ "Check", "whether", "the", "delegate", "type", "implements", "or", "extends", "all", "decorated", "types", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/Decorators.java#L134-L143
163,244
weld/core
impl/src/main/java/org/jboss/weld/util/Decorators.java
Decorators.checkAbstractMethods
public static <T> void checkAbstractMethods(Set<Type> decoratedTypes, EnhancedAnnotatedType<T> type, BeanManagerImpl beanManager) { if (decoratedTypes == null) { decoratedTypes = new HashSet<Type>(type.getInterfaceClosure()); decoratedTypes.remove(Serializable.class); } Set<MethodSignature> signatures = new HashSet<MethodSignature>(); for (Type decoratedType : decoratedTypes) { for (EnhancedAnnotatedMethod<?, ?> method : ClassTransformer.instance(beanManager) .getEnhancedAnnotatedType(Reflections.getRawType(decoratedType), beanManager.getId()).getEnhancedMethods()) { signatures.add(method.getSignature()); } } for (EnhancedAnnotatedMethod<?, ?> method : type.getEnhancedMethods()) { if (Reflections.isAbstract(((AnnotatedMethod<?>) method).getJavaMember())) { MethodSignature methodSignature = method.getSignature(); if (!signatures.contains(methodSignature)) { throw BeanLogger.LOG.abstractMethodMustMatchDecoratedType(method, Formats.formatAsStackTraceElement(method.getJavaMember())); } } } }
java
public static <T> void checkAbstractMethods(Set<Type> decoratedTypes, EnhancedAnnotatedType<T> type, BeanManagerImpl beanManager) { if (decoratedTypes == null) { decoratedTypes = new HashSet<Type>(type.getInterfaceClosure()); decoratedTypes.remove(Serializable.class); } Set<MethodSignature> signatures = new HashSet<MethodSignature>(); for (Type decoratedType : decoratedTypes) { for (EnhancedAnnotatedMethod<?, ?> method : ClassTransformer.instance(beanManager) .getEnhancedAnnotatedType(Reflections.getRawType(decoratedType), beanManager.getId()).getEnhancedMethods()) { signatures.add(method.getSignature()); } } for (EnhancedAnnotatedMethod<?, ?> method : type.getEnhancedMethods()) { if (Reflections.isAbstract(((AnnotatedMethod<?>) method).getJavaMember())) { MethodSignature methodSignature = method.getSignature(); if (!signatures.contains(methodSignature)) { throw BeanLogger.LOG.abstractMethodMustMatchDecoratedType(method, Formats.formatAsStackTraceElement(method.getJavaMember())); } } } }
[ "public", "static", "<", "T", ">", "void", "checkAbstractMethods", "(", "Set", "<", "Type", ">", "decoratedTypes", ",", "EnhancedAnnotatedType", "<", "T", ">", "type", ",", "BeanManagerImpl", "beanManager", ")", "{", "if", "(", "decoratedTypes", "==", "null", ")", "{", "decoratedTypes", "=", "new", "HashSet", "<", "Type", ">", "(", "type", ".", "getInterfaceClosure", "(", ")", ")", ";", "decoratedTypes", ".", "remove", "(", "Serializable", ".", "class", ")", ";", "}", "Set", "<", "MethodSignature", ">", "signatures", "=", "new", "HashSet", "<", "MethodSignature", ">", "(", ")", ";", "for", "(", "Type", "decoratedType", ":", "decoratedTypes", ")", "{", "for", "(", "EnhancedAnnotatedMethod", "<", "?", ",", "?", ">", "method", ":", "ClassTransformer", ".", "instance", "(", "beanManager", ")", ".", "getEnhancedAnnotatedType", "(", "Reflections", ".", "getRawType", "(", "decoratedType", ")", ",", "beanManager", ".", "getId", "(", ")", ")", ".", "getEnhancedMethods", "(", ")", ")", "{", "signatures", ".", "add", "(", "method", ".", "getSignature", "(", ")", ")", ";", "}", "}", "for", "(", "EnhancedAnnotatedMethod", "<", "?", ",", "?", ">", "method", ":", "type", ".", "getEnhancedMethods", "(", ")", ")", "{", "if", "(", "Reflections", ".", "isAbstract", "(", "(", "(", "AnnotatedMethod", "<", "?", ">", ")", "method", ")", ".", "getJavaMember", "(", ")", ")", ")", "{", "MethodSignature", "methodSignature", "=", "method", ".", "getSignature", "(", ")", ";", "if", "(", "!", "signatures", ".", "contains", "(", "methodSignature", ")", ")", "{", "throw", "BeanLogger", ".", "LOG", ".", "abstractMethodMustMatchDecoratedType", "(", "method", ",", "Formats", ".", "formatAsStackTraceElement", "(", "method", ".", "getJavaMember", "(", ")", ")", ")", ";", "}", "}", "}", "}" ]
Check all abstract methods are declared by the decorated types. @param type @param beanManager @param delegateType @throws DefinitionException If any of the abstract methods is not declared by the decorated types
[ "Check", "all", "abstract", "methods", "are", "declared", "by", "the", "decorated", "types", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/Decorators.java#L153-L177
163,245
weld/core
impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
AbstractBean.checkSpecialization
public void checkSpecialization() { if (isSpecializing()) { boolean isNameDefined = getAnnotated().isAnnotationPresent(Named.class); String previousSpecializedBeanName = null; for (AbstractBean<?, ?> specializedBean : getSpecializedBeans()) { String name = specializedBean.getName(); if (previousSpecializedBeanName != null && name != null && !previousSpecializedBeanName.equals(specializedBean.getName())) { // there may be multiple beans specialized by this bean - make sure they all share the same name throw BeanLogger.LOG.beansWithDifferentBeanNamesCannotBeSpecialized(previousSpecializedBeanName, specializedBean.getName(), this); } previousSpecializedBeanName = name; if (isNameDefined && name != null) { throw BeanLogger.LOG.nameNotAllowedOnSpecialization(getAnnotated(), specializedBean.getAnnotated()); } // When a specializing bean extends the raw type of a generic superclass, types of the generic superclass are // added into types of the specializing bean because of assignability rules. However, ParameterizedTypes among // these types are NOT types of the specializing bean (that's the way java works) boolean rawInsteadOfGeneric = (this instanceof AbstractClassBean<?> && specializedBean.getBeanClass().getTypeParameters().length > 0 && !(((AbstractClassBean<?>) this).getBeanClass().getGenericSuperclass() instanceof ParameterizedType)); for (Type specializedType : specializedBean.getTypes()) { if (rawInsteadOfGeneric && specializedType instanceof ParameterizedType) { throw BeanLogger.LOG.specializingBeanMissingSpecializedType(this, specializedType, specializedBean); } boolean contains = getTypes().contains(specializedType); if (!contains) { for (Type specializingType : getTypes()) { // In case 'type' is a ParameterizedType, two bean types equivalent in the CDI sense may not be // equal in the java sense. Therefore we have to use our own equality util. if (TypeEqualitySpecializationUtils.areTheSame(specializingType, specializedType)) { contains = true; break; } } } if (!contains) { throw BeanLogger.LOG.specializingBeanMissingSpecializedType(this, specializedType, specializedBean); } } } } }
java
public void checkSpecialization() { if (isSpecializing()) { boolean isNameDefined = getAnnotated().isAnnotationPresent(Named.class); String previousSpecializedBeanName = null; for (AbstractBean<?, ?> specializedBean : getSpecializedBeans()) { String name = specializedBean.getName(); if (previousSpecializedBeanName != null && name != null && !previousSpecializedBeanName.equals(specializedBean.getName())) { // there may be multiple beans specialized by this bean - make sure they all share the same name throw BeanLogger.LOG.beansWithDifferentBeanNamesCannotBeSpecialized(previousSpecializedBeanName, specializedBean.getName(), this); } previousSpecializedBeanName = name; if (isNameDefined && name != null) { throw BeanLogger.LOG.nameNotAllowedOnSpecialization(getAnnotated(), specializedBean.getAnnotated()); } // When a specializing bean extends the raw type of a generic superclass, types of the generic superclass are // added into types of the specializing bean because of assignability rules. However, ParameterizedTypes among // these types are NOT types of the specializing bean (that's the way java works) boolean rawInsteadOfGeneric = (this instanceof AbstractClassBean<?> && specializedBean.getBeanClass().getTypeParameters().length > 0 && !(((AbstractClassBean<?>) this).getBeanClass().getGenericSuperclass() instanceof ParameterizedType)); for (Type specializedType : specializedBean.getTypes()) { if (rawInsteadOfGeneric && specializedType instanceof ParameterizedType) { throw BeanLogger.LOG.specializingBeanMissingSpecializedType(this, specializedType, specializedBean); } boolean contains = getTypes().contains(specializedType); if (!contains) { for (Type specializingType : getTypes()) { // In case 'type' is a ParameterizedType, two bean types equivalent in the CDI sense may not be // equal in the java sense. Therefore we have to use our own equality util. if (TypeEqualitySpecializationUtils.areTheSame(specializingType, specializedType)) { contains = true; break; } } } if (!contains) { throw BeanLogger.LOG.specializingBeanMissingSpecializedType(this, specializedType, specializedBean); } } } } }
[ "public", "void", "checkSpecialization", "(", ")", "{", "if", "(", "isSpecializing", "(", ")", ")", "{", "boolean", "isNameDefined", "=", "getAnnotated", "(", ")", ".", "isAnnotationPresent", "(", "Named", ".", "class", ")", ";", "String", "previousSpecializedBeanName", "=", "null", ";", "for", "(", "AbstractBean", "<", "?", ",", "?", ">", "specializedBean", ":", "getSpecializedBeans", "(", ")", ")", "{", "String", "name", "=", "specializedBean", ".", "getName", "(", ")", ";", "if", "(", "previousSpecializedBeanName", "!=", "null", "&&", "name", "!=", "null", "&&", "!", "previousSpecializedBeanName", ".", "equals", "(", "specializedBean", ".", "getName", "(", ")", ")", ")", "{", "// there may be multiple beans specialized by this bean - make sure they all share the same name", "throw", "BeanLogger", ".", "LOG", ".", "beansWithDifferentBeanNamesCannotBeSpecialized", "(", "previousSpecializedBeanName", ",", "specializedBean", ".", "getName", "(", ")", ",", "this", ")", ";", "}", "previousSpecializedBeanName", "=", "name", ";", "if", "(", "isNameDefined", "&&", "name", "!=", "null", ")", "{", "throw", "BeanLogger", ".", "LOG", ".", "nameNotAllowedOnSpecialization", "(", "getAnnotated", "(", ")", ",", "specializedBean", ".", "getAnnotated", "(", ")", ")", ";", "}", "// When a specializing bean extends the raw type of a generic superclass, types of the generic superclass are", "// added into types of the specializing bean because of assignability rules. However, ParameterizedTypes among", "// these types are NOT types of the specializing bean (that's the way java works)", "boolean", "rawInsteadOfGeneric", "=", "(", "this", "instanceof", "AbstractClassBean", "<", "?", ">", "&&", "specializedBean", ".", "getBeanClass", "(", ")", ".", "getTypeParameters", "(", ")", ".", "length", ">", "0", "&&", "!", "(", "(", "(", "AbstractClassBean", "<", "?", ">", ")", "this", ")", ".", "getBeanClass", "(", ")", ".", "getGenericSuperclass", "(", ")", "instanceof", "ParameterizedType", ")", ")", ";", "for", "(", "Type", "specializedType", ":", "specializedBean", ".", "getTypes", "(", ")", ")", "{", "if", "(", "rawInsteadOfGeneric", "&&", "specializedType", "instanceof", "ParameterizedType", ")", "{", "throw", "BeanLogger", ".", "LOG", ".", "specializingBeanMissingSpecializedType", "(", "this", ",", "specializedType", ",", "specializedBean", ")", ";", "}", "boolean", "contains", "=", "getTypes", "(", ")", ".", "contains", "(", "specializedType", ")", ";", "if", "(", "!", "contains", ")", "{", "for", "(", "Type", "specializingType", ":", "getTypes", "(", ")", ")", "{", "// In case 'type' is a ParameterizedType, two bean types equivalent in the CDI sense may not be", "// equal in the java sense. Therefore we have to use our own equality util.", "if", "(", "TypeEqualitySpecializationUtils", ".", "areTheSame", "(", "specializingType", ",", "specializedType", ")", ")", "{", "contains", "=", "true", ";", "break", ";", "}", "}", "}", "if", "(", "!", "contains", ")", "{", "throw", "BeanLogger", ".", "LOG", ".", "specializingBeanMissingSpecializedType", "(", "this", ",", "specializedType", ",", "specializedBean", ")", ";", "}", "}", "}", "}", "}" ]
Validates specialization if this bean specializes another bean.
[ "Validates", "specialization", "if", "this", "bean", "specializes", "another", "bean", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java#L116-L158
163,246
weld/core
impl/src/main/java/org/jboss/weld/bootstrap/BeanDeploymentModule.java
BeanDeploymentModule.fireEvent
public void fireEvent(Type eventType, Object event, Annotation... qualifiers) { final EventMetadata metadata = new EventMetadataImpl(eventType, null, qualifiers); notifier.fireEvent(eventType, event, metadata, qualifiers); }
java
public void fireEvent(Type eventType, Object event, Annotation... qualifiers) { final EventMetadata metadata = new EventMetadataImpl(eventType, null, qualifiers); notifier.fireEvent(eventType, event, metadata, qualifiers); }
[ "public", "void", "fireEvent", "(", "Type", "eventType", ",", "Object", "event", ",", "Annotation", "...", "qualifiers", ")", "{", "final", "EventMetadata", "metadata", "=", "new", "EventMetadataImpl", "(", "eventType", ",", "null", ",", "qualifiers", ")", ";", "notifier", ".", "fireEvent", "(", "eventType", ",", "event", ",", "metadata", ",", "qualifiers", ")", ";", "}" ]
Fire an event and notify observers that belong to this module. @param eventType @param event @param qualifiers
[ "Fire", "an", "event", "and", "notify", "observers", "that", "belong", "to", "this", "module", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeploymentModule.java#L91-L94
163,247
weld/core
impl/src/main/java/org/jboss/weld/util/Defaults.java
Defaults.getJlsDefaultValue
@SuppressWarnings("unchecked") public static <T> T getJlsDefaultValue(Class<T> type) { if(!type.isPrimitive()) { return null; } return (T) JLS_PRIMITIVE_DEFAULT_VALUES.get(type); }
java
@SuppressWarnings("unchecked") public static <T> T getJlsDefaultValue(Class<T> type) { if(!type.isPrimitive()) { return null; } return (T) JLS_PRIMITIVE_DEFAULT_VALUES.get(type); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "getJlsDefaultValue", "(", "Class", "<", "T", ">", "type", ")", "{", "if", "(", "!", "type", ".", "isPrimitive", "(", ")", ")", "{", "return", "null", ";", "}", "return", "(", "T", ")", "JLS_PRIMITIVE_DEFAULT_VALUES", ".", "get", "(", "type", ")", ";", "}" ]
See also JLS8, 4.12.5 Initial Values of Variables. @param type @return the default value for the given type as defined by JLS
[ "See", "also", "JLS8", "4", ".", "12", ".", "5", "Initial", "Values", "of", "Variables", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/Defaults.java#L53-L59
163,248
weld/core
probe/core/src/main/java/org/jboss/weld/probe/ProbeExtension.java
ProbeExtension.afterDeploymentValidation
public void afterDeploymentValidation(@Observes @Priority(1) AfterDeploymentValidation event, BeanManager beanManager) { BeanManagerImpl manager = BeanManagerProxy.unwrap(beanManager); probe.init(manager); if (isJMXSupportEnabled(manager)) { try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); mbs.registerMBean(new ProbeDynamicMBean(jsonDataProvider, JsonDataProvider.class), constructProbeJsonDataMBeanName(manager, probe)); } catch (MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) { event.addDeploymentProblem(ProbeLogger.LOG.unableToRegisterMBean(JsonDataProvider.class, manager.getContextId(), e)); } } addContainerLifecycleEvent(event, null, beanManager); exportDataIfNeeded(manager); }
java
public void afterDeploymentValidation(@Observes @Priority(1) AfterDeploymentValidation event, BeanManager beanManager) { BeanManagerImpl manager = BeanManagerProxy.unwrap(beanManager); probe.init(manager); if (isJMXSupportEnabled(manager)) { try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); mbs.registerMBean(new ProbeDynamicMBean(jsonDataProvider, JsonDataProvider.class), constructProbeJsonDataMBeanName(manager, probe)); } catch (MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) { event.addDeploymentProblem(ProbeLogger.LOG.unableToRegisterMBean(JsonDataProvider.class, manager.getContextId(), e)); } } addContainerLifecycleEvent(event, null, beanManager); exportDataIfNeeded(manager); }
[ "public", "void", "afterDeploymentValidation", "(", "@", "Observes", "@", "Priority", "(", "1", ")", "AfterDeploymentValidation", "event", ",", "BeanManager", "beanManager", ")", "{", "BeanManagerImpl", "manager", "=", "BeanManagerProxy", ".", "unwrap", "(", "beanManager", ")", ";", "probe", ".", "init", "(", "manager", ")", ";", "if", "(", "isJMXSupportEnabled", "(", "manager", ")", ")", "{", "try", "{", "MBeanServer", "mbs", "=", "ManagementFactory", ".", "getPlatformMBeanServer", "(", ")", ";", "mbs", ".", "registerMBean", "(", "new", "ProbeDynamicMBean", "(", "jsonDataProvider", ",", "JsonDataProvider", ".", "class", ")", ",", "constructProbeJsonDataMBeanName", "(", "manager", ",", "probe", ")", ")", ";", "}", "catch", "(", "MalformedObjectNameException", "|", "InstanceAlreadyExistsException", "|", "MBeanRegistrationException", "|", "NotCompliantMBeanException", "e", ")", "{", "event", ".", "addDeploymentProblem", "(", "ProbeLogger", ".", "LOG", ".", "unableToRegisterMBean", "(", "JsonDataProvider", ".", "class", ",", "manager", ".", "getContextId", "(", ")", ",", "e", ")", ")", ";", "}", "}", "addContainerLifecycleEvent", "(", "event", ",", "null", ",", "beanManager", ")", ";", "exportDataIfNeeded", "(", "manager", ")", ";", "}" ]
any possible bean invocations from other ADV observers
[ "any", "possible", "bean", "invocations", "from", "other", "ADV", "observers" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/probe/core/src/main/java/org/jboss/weld/probe/ProbeExtension.java#L165-L178
163,249
weld/core
impl/src/main/java/org/jboss/weld/metadata/Selectors.java
Selectors.matchPath
static boolean matchPath(String[] tokenizedPattern, String[] strDirs, boolean isCaseSensitive) { int patIdxStart = 0; int patIdxEnd = tokenizedPattern.length - 1; int strIdxStart = 0; int strIdxEnd = strDirs.length - 1; // up to first '**' while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = tokenizedPattern[patIdxStart]; if (patDir.equals(DEEP_TREE_MATCH)) { break; } if (!match(patDir, strDirs[strIdxStart], isCaseSensitive)) { return false; } patIdxStart++; strIdxStart++; } if (strIdxStart > strIdxEnd) { // String is exhausted for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) { return false; } } return true; } else { if (patIdxStart > patIdxEnd) { // String not exhausted, but pattern is. Failure. return false; } } // up to last '**' while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = tokenizedPattern[patIdxEnd]; if (patDir.equals(DEEP_TREE_MATCH)) { break; } if (!match(patDir, strDirs[strIdxEnd], isCaseSensitive)) { return false; } patIdxEnd--; strIdxEnd--; } if (strIdxStart > strIdxEnd) { // String is exhausted for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) { return false; } } return true; } while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { int patIdxTmp = -1; for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { if (tokenizedPattern[i].equals(DEEP_TREE_MATCH)) { patIdxTmp = i; break; } } if (patIdxTmp == patIdxStart + 1) { // '**/**' situation, so skip one patIdxStart++; continue; } // Find the pattern between padIdxStart & padIdxTmp in str between // strIdxStart & strIdxEnd int patLength = (patIdxTmp - patIdxStart - 1); int strLength = (strIdxEnd - strIdxStart + 1); int foundIdx = -1; strLoop: for (int i = 0; i <= strLength - patLength; i++) { for (int j = 0; j < patLength; j++) { String subPat = tokenizedPattern[patIdxStart + j + 1]; String subStr = strDirs[strIdxStart + i + j]; if (!match(subPat, subStr, isCaseSensitive)) { continue strLoop; } } foundIdx = strIdxStart + i; break; } if (foundIdx == -1) { return false; } patIdxStart = patIdxTmp; strIdxStart = foundIdx + patLength; } for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) { return false; } } return true; }
java
static boolean matchPath(String[] tokenizedPattern, String[] strDirs, boolean isCaseSensitive) { int patIdxStart = 0; int patIdxEnd = tokenizedPattern.length - 1; int strIdxStart = 0; int strIdxEnd = strDirs.length - 1; // up to first '**' while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = tokenizedPattern[patIdxStart]; if (patDir.equals(DEEP_TREE_MATCH)) { break; } if (!match(patDir, strDirs[strIdxStart], isCaseSensitive)) { return false; } patIdxStart++; strIdxStart++; } if (strIdxStart > strIdxEnd) { // String is exhausted for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) { return false; } } return true; } else { if (patIdxStart > patIdxEnd) { // String not exhausted, but pattern is. Failure. return false; } } // up to last '**' while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = tokenizedPattern[patIdxEnd]; if (patDir.equals(DEEP_TREE_MATCH)) { break; } if (!match(patDir, strDirs[strIdxEnd], isCaseSensitive)) { return false; } patIdxEnd--; strIdxEnd--; } if (strIdxStart > strIdxEnd) { // String is exhausted for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) { return false; } } return true; } while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { int patIdxTmp = -1; for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { if (tokenizedPattern[i].equals(DEEP_TREE_MATCH)) { patIdxTmp = i; break; } } if (patIdxTmp == patIdxStart + 1) { // '**/**' situation, so skip one patIdxStart++; continue; } // Find the pattern between padIdxStart & padIdxTmp in str between // strIdxStart & strIdxEnd int patLength = (patIdxTmp - patIdxStart - 1); int strLength = (strIdxEnd - strIdxStart + 1); int foundIdx = -1; strLoop: for (int i = 0; i <= strLength - patLength; i++) { for (int j = 0; j < patLength; j++) { String subPat = tokenizedPattern[patIdxStart + j + 1]; String subStr = strDirs[strIdxStart + i + j]; if (!match(subPat, subStr, isCaseSensitive)) { continue strLoop; } } foundIdx = strIdxStart + i; break; } if (foundIdx == -1) { return false; } patIdxStart = patIdxTmp; strIdxStart = foundIdx + patLength; } for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) { return false; } } return true; }
[ "static", "boolean", "matchPath", "(", "String", "[", "]", "tokenizedPattern", ",", "String", "[", "]", "strDirs", ",", "boolean", "isCaseSensitive", ")", "{", "int", "patIdxStart", "=", "0", ";", "int", "patIdxEnd", "=", "tokenizedPattern", ".", "length", "-", "1", ";", "int", "strIdxStart", "=", "0", ";", "int", "strIdxEnd", "=", "strDirs", ".", "length", "-", "1", ";", "// up to first '**'", "while", "(", "patIdxStart", "<=", "patIdxEnd", "&&", "strIdxStart", "<=", "strIdxEnd", ")", "{", "String", "patDir", "=", "tokenizedPattern", "[", "patIdxStart", "]", ";", "if", "(", "patDir", ".", "equals", "(", "DEEP_TREE_MATCH", ")", ")", "{", "break", ";", "}", "if", "(", "!", "match", "(", "patDir", ",", "strDirs", "[", "strIdxStart", "]", ",", "isCaseSensitive", ")", ")", "{", "return", "false", ";", "}", "patIdxStart", "++", ";", "strIdxStart", "++", ";", "}", "if", "(", "strIdxStart", ">", "strIdxEnd", ")", "{", "// String is exhausted", "for", "(", "int", "i", "=", "patIdxStart", ";", "i", "<=", "patIdxEnd", ";", "i", "++", ")", "{", "if", "(", "!", "tokenizedPattern", "[", "i", "]", ".", "equals", "(", "DEEP_TREE_MATCH", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "else", "{", "if", "(", "patIdxStart", ">", "patIdxEnd", ")", "{", "// String not exhausted, but pattern is. Failure.", "return", "false", ";", "}", "}", "// up to last '**'", "while", "(", "patIdxStart", "<=", "patIdxEnd", "&&", "strIdxStart", "<=", "strIdxEnd", ")", "{", "String", "patDir", "=", "tokenizedPattern", "[", "patIdxEnd", "]", ";", "if", "(", "patDir", ".", "equals", "(", "DEEP_TREE_MATCH", ")", ")", "{", "break", ";", "}", "if", "(", "!", "match", "(", "patDir", ",", "strDirs", "[", "strIdxEnd", "]", ",", "isCaseSensitive", ")", ")", "{", "return", "false", ";", "}", "patIdxEnd", "--", ";", "strIdxEnd", "--", ";", "}", "if", "(", "strIdxStart", ">", "strIdxEnd", ")", "{", "// String is exhausted", "for", "(", "int", "i", "=", "patIdxStart", ";", "i", "<=", "patIdxEnd", ";", "i", "++", ")", "{", "if", "(", "!", "tokenizedPattern", "[", "i", "]", ".", "equals", "(", "DEEP_TREE_MATCH", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "while", "(", "patIdxStart", "!=", "patIdxEnd", "&&", "strIdxStart", "<=", "strIdxEnd", ")", "{", "int", "patIdxTmp", "=", "-", "1", ";", "for", "(", "int", "i", "=", "patIdxStart", "+", "1", ";", "i", "<=", "patIdxEnd", ";", "i", "++", ")", "{", "if", "(", "tokenizedPattern", "[", "i", "]", ".", "equals", "(", "DEEP_TREE_MATCH", ")", ")", "{", "patIdxTmp", "=", "i", ";", "break", ";", "}", "}", "if", "(", "patIdxTmp", "==", "patIdxStart", "+", "1", ")", "{", "// '**/**' situation, so skip one", "patIdxStart", "++", ";", "continue", ";", "}", "// Find the pattern between padIdxStart & padIdxTmp in str between", "// strIdxStart & strIdxEnd", "int", "patLength", "=", "(", "patIdxTmp", "-", "patIdxStart", "-", "1", ")", ";", "int", "strLength", "=", "(", "strIdxEnd", "-", "strIdxStart", "+", "1", ")", ";", "int", "foundIdx", "=", "-", "1", ";", "strLoop", ":", "for", "(", "int", "i", "=", "0", ";", "i", "<=", "strLength", "-", "patLength", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "patLength", ";", "j", "++", ")", "{", "String", "subPat", "=", "tokenizedPattern", "[", "patIdxStart", "+", "j", "+", "1", "]", ";", "String", "subStr", "=", "strDirs", "[", "strIdxStart", "+", "i", "+", "j", "]", ";", "if", "(", "!", "match", "(", "subPat", ",", "subStr", ",", "isCaseSensitive", ")", ")", "{", "continue", "strLoop", ";", "}", "}", "foundIdx", "=", "strIdxStart", "+", "i", ";", "break", ";", "}", "if", "(", "foundIdx", "==", "-", "1", ")", "{", "return", "false", ";", "}", "patIdxStart", "=", "patIdxTmp", ";", "strIdxStart", "=", "foundIdx", "+", "patLength", ";", "}", "for", "(", "int", "i", "=", "patIdxStart", ";", "i", "<=", "patIdxEnd", ";", "i", "++", ")", "{", "if", "(", "!", "tokenizedPattern", "[", "i", "]", ".", "equals", "(", "DEEP_TREE_MATCH", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Core implementation of matchPath. It is isolated so that it can be called from TokenizedPattern.
[ "Core", "implementation", "of", "matchPath", ".", "It", "is", "isolated", "so", "that", "it", "can", "be", "called", "from", "TokenizedPattern", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/metadata/Selectors.java#L81-L183
163,250
weld/core
impl/src/main/java/org/jboss/weld/metadata/Selectors.java
Selectors.tokenize
static String[] tokenize(String str) { char sep = '.'; int start = 0; int len = str.length(); int count = 0; for (int pos = 0; pos < len; pos++) { if (str.charAt(pos) == sep) { if (pos != start) { count++; } start = pos + 1; } } if (len != start) { count++; } String[] l = new String[count]; count = 0; start = 0; for (int pos = 0; pos < len; pos++) { if (str.charAt(pos) == sep) { if (pos != start) { String tok = str.substring(start, pos); l[count++] = tok; } start = pos + 1; } } if (len != start) { String tok = str.substring(start); l[count/* ++ */] = tok; } return l; }
java
static String[] tokenize(String str) { char sep = '.'; int start = 0; int len = str.length(); int count = 0; for (int pos = 0; pos < len; pos++) { if (str.charAt(pos) == sep) { if (pos != start) { count++; } start = pos + 1; } } if (len != start) { count++; } String[] l = new String[count]; count = 0; start = 0; for (int pos = 0; pos < len; pos++) { if (str.charAt(pos) == sep) { if (pos != start) { String tok = str.substring(start, pos); l[count++] = tok; } start = pos + 1; } } if (len != start) { String tok = str.substring(start); l[count/* ++ */] = tok; } return l; }
[ "static", "String", "[", "]", "tokenize", "(", "String", "str", ")", "{", "char", "sep", "=", "'", "'", ";", "int", "start", "=", "0", ";", "int", "len", "=", "str", ".", "length", "(", ")", ";", "int", "count", "=", "0", ";", "for", "(", "int", "pos", "=", "0", ";", "pos", "<", "len", ";", "pos", "++", ")", "{", "if", "(", "str", ".", "charAt", "(", "pos", ")", "==", "sep", ")", "{", "if", "(", "pos", "!=", "start", ")", "{", "count", "++", ";", "}", "start", "=", "pos", "+", "1", ";", "}", "}", "if", "(", "len", "!=", "start", ")", "{", "count", "++", ";", "}", "String", "[", "]", "l", "=", "new", "String", "[", "count", "]", ";", "count", "=", "0", ";", "start", "=", "0", ";", "for", "(", "int", "pos", "=", "0", ";", "pos", "<", "len", ";", "pos", "++", ")", "{", "if", "(", "str", ".", "charAt", "(", "pos", ")", "==", "sep", ")", "{", "if", "(", "pos", "!=", "start", ")", "{", "String", "tok", "=", "str", ".", "substring", "(", "start", ",", "pos", ")", ";", "l", "[", "count", "++", "]", "=", "tok", ";", "}", "start", "=", "pos", "+", "1", ";", "}", "}", "if", "(", "len", "!=", "start", ")", "{", "String", "tok", "=", "str", ".", "substring", "(", "start", ")", ";", "l", "[", "count", "/* ++ */", "]", "=", "tok", ";", "}", "return", "l", ";", "}" ]
Tokenize the the string as a package hierarchy @param str @return
[ "Tokenize", "the", "the", "string", "as", "a", "package", "hierarchy" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/metadata/Selectors.java#L347-L381
163,251
weld/core
impl/src/main/java/org/jboss/weld/bean/proxy/RunWithinInterceptionDecorationContextGenerator.java
RunWithinInterceptionDecorationContextGenerator.endIfStarted
void endIfStarted(CodeAttribute b, ClassMethod method) { b.aload(getLocalVariableIndex(0)); b.dup(); final BranchEnd ifnotnull = b.ifnull(); b.checkcast(Stack.class); b.invokevirtual(Stack.class.getName(), END_INTERCEPTOR_CONTEXT_METHOD_NAME, EMPTY_PARENTHESES + VOID_CLASS_DESCRIPTOR); BranchEnd ifnull = b.gotoInstruction(); b.branchEnd(ifnotnull); b.pop(); // remove null Stack b.branchEnd(ifnull); }
java
void endIfStarted(CodeAttribute b, ClassMethod method) { b.aload(getLocalVariableIndex(0)); b.dup(); final BranchEnd ifnotnull = b.ifnull(); b.checkcast(Stack.class); b.invokevirtual(Stack.class.getName(), END_INTERCEPTOR_CONTEXT_METHOD_NAME, EMPTY_PARENTHESES + VOID_CLASS_DESCRIPTOR); BranchEnd ifnull = b.gotoInstruction(); b.branchEnd(ifnotnull); b.pop(); // remove null Stack b.branchEnd(ifnull); }
[ "void", "endIfStarted", "(", "CodeAttribute", "b", ",", "ClassMethod", "method", ")", "{", "b", ".", "aload", "(", "getLocalVariableIndex", "(", "0", ")", ")", ";", "b", ".", "dup", "(", ")", ";", "final", "BranchEnd", "ifnotnull", "=", "b", ".", "ifnull", "(", ")", ";", "b", ".", "checkcast", "(", "Stack", ".", "class", ")", ";", "b", ".", "invokevirtual", "(", "Stack", ".", "class", ".", "getName", "(", ")", ",", "END_INTERCEPTOR_CONTEXT_METHOD_NAME", ",", "EMPTY_PARENTHESES", "+", "VOID_CLASS_DESCRIPTOR", ")", ";", "BranchEnd", "ifnull", "=", "b", ".", "gotoInstruction", "(", ")", ";", "b", ".", "branchEnd", "(", "ifnotnull", ")", ";", "b", ".", "pop", "(", ")", ";", "// remove null Stack", "b", ".", "branchEnd", "(", "ifnull", ")", ";", "}" ]
Ends interception context if it was previously stated. This is indicated by a local variable with index 0.
[ "Ends", "interception", "context", "if", "it", "was", "previously", "stated", ".", "This", "is", "indicated", "by", "a", "local", "variable", "with", "index", "0", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bean/proxy/RunWithinInterceptionDecorationContextGenerator.java#L117-L127
163,252
weld/core
impl/src/main/java/org/jboss/weld/contexts/AbstractContext.java
AbstractContext.get
@Override @SuppressFBWarnings(value = "UL_UNRELEASED_LOCK", justification = "False positive from FindBugs") public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { if (!isActive()) { throw new ContextNotActiveException(); } checkContextInitialized(); final BeanStore beanStore = getBeanStore(); if (beanStore == null) { return null; } if (contextual == null) { throw ContextLogger.LOG.contextualIsNull(); } BeanIdentifier id = getId(contextual); ContextualInstance<T> beanInstance = beanStore.get(id); if (beanInstance != null) { return beanInstance.getInstance(); } else if (creationalContext != null) { LockedBean lock = null; try { if (multithreaded) { lock = beanStore.lock(id); beanInstance = beanStore.get(id); if (beanInstance != null) { return beanInstance.getInstance(); } } T instance = contextual.create(creationalContext); if (instance != null) { beanInstance = new SerializableContextualInstanceImpl<Contextual<T>, T>(contextual, instance, creationalContext, serviceRegistry.get(ContextualStore.class)); beanStore.put(id, beanInstance); } return instance; } finally { if (lock != null) { lock.unlock(); } } } else { return null; } }
java
@Override @SuppressFBWarnings(value = "UL_UNRELEASED_LOCK", justification = "False positive from FindBugs") public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { if (!isActive()) { throw new ContextNotActiveException(); } checkContextInitialized(); final BeanStore beanStore = getBeanStore(); if (beanStore == null) { return null; } if (contextual == null) { throw ContextLogger.LOG.contextualIsNull(); } BeanIdentifier id = getId(contextual); ContextualInstance<T> beanInstance = beanStore.get(id); if (beanInstance != null) { return beanInstance.getInstance(); } else if (creationalContext != null) { LockedBean lock = null; try { if (multithreaded) { lock = beanStore.lock(id); beanInstance = beanStore.get(id); if (beanInstance != null) { return beanInstance.getInstance(); } } T instance = contextual.create(creationalContext); if (instance != null) { beanInstance = new SerializableContextualInstanceImpl<Contextual<T>, T>(contextual, instance, creationalContext, serviceRegistry.get(ContextualStore.class)); beanStore.put(id, beanInstance); } return instance; } finally { if (lock != null) { lock.unlock(); } } } else { return null; } }
[ "@", "Override", "@", "SuppressFBWarnings", "(", "value", "=", "\"UL_UNRELEASED_LOCK\"", ",", "justification", "=", "\"False positive from FindBugs\"", ")", "public", "<", "T", ">", "T", "get", "(", "Contextual", "<", "T", ">", "contextual", ",", "CreationalContext", "<", "T", ">", "creationalContext", ")", "{", "if", "(", "!", "isActive", "(", ")", ")", "{", "throw", "new", "ContextNotActiveException", "(", ")", ";", "}", "checkContextInitialized", "(", ")", ";", "final", "BeanStore", "beanStore", "=", "getBeanStore", "(", ")", ";", "if", "(", "beanStore", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "contextual", "==", "null", ")", "{", "throw", "ContextLogger", ".", "LOG", ".", "contextualIsNull", "(", ")", ";", "}", "BeanIdentifier", "id", "=", "getId", "(", "contextual", ")", ";", "ContextualInstance", "<", "T", ">", "beanInstance", "=", "beanStore", ".", "get", "(", "id", ")", ";", "if", "(", "beanInstance", "!=", "null", ")", "{", "return", "beanInstance", ".", "getInstance", "(", ")", ";", "}", "else", "if", "(", "creationalContext", "!=", "null", ")", "{", "LockedBean", "lock", "=", "null", ";", "try", "{", "if", "(", "multithreaded", ")", "{", "lock", "=", "beanStore", ".", "lock", "(", "id", ")", ";", "beanInstance", "=", "beanStore", ".", "get", "(", "id", ")", ";", "if", "(", "beanInstance", "!=", "null", ")", "{", "return", "beanInstance", ".", "getInstance", "(", ")", ";", "}", "}", "T", "instance", "=", "contextual", ".", "create", "(", "creationalContext", ")", ";", "if", "(", "instance", "!=", "null", ")", "{", "beanInstance", "=", "new", "SerializableContextualInstanceImpl", "<", "Contextual", "<", "T", ">", ",", "T", ">", "(", "contextual", ",", "instance", ",", "creationalContext", ",", "serviceRegistry", ".", "get", "(", "ContextualStore", ".", "class", ")", ")", ";", "beanStore", ".", "put", "(", "id", ",", "beanInstance", ")", ";", "}", "return", "instance", ";", "}", "finally", "{", "if", "(", "lock", "!=", "null", ")", "{", "lock", ".", "unlock", "(", ")", ";", "}", "}", "}", "else", "{", "return", "null", ";", "}", "}" ]
Get the bean if it exists in the contexts. @return An instance of the bean @throws ContextNotActiveException if the context is not active @see javax.enterprise.context.spi.Context#get(BaseBean, boolean)
[ "Get", "the", "bean", "if", "it", "exists", "in", "the", "contexts", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/contexts/AbstractContext.java#L68-L110
163,253
weld/core
impl/src/main/java/org/jboss/weld/contexts/AbstractContext.java
AbstractContext.destroy
protected void destroy() { ContextLogger.LOG.contextCleared(this); final BeanStore beanStore = getBeanStore(); if (beanStore == null) { throw ContextLogger.LOG.noBeanStoreAvailable(this); } for (BeanIdentifier id : beanStore) { destroyContextualInstance(beanStore.get(id)); } beanStore.clear(); }
java
protected void destroy() { ContextLogger.LOG.contextCleared(this); final BeanStore beanStore = getBeanStore(); if (beanStore == null) { throw ContextLogger.LOG.noBeanStoreAvailable(this); } for (BeanIdentifier id : beanStore) { destroyContextualInstance(beanStore.get(id)); } beanStore.clear(); }
[ "protected", "void", "destroy", "(", ")", "{", "ContextLogger", ".", "LOG", ".", "contextCleared", "(", "this", ")", ";", "final", "BeanStore", "beanStore", "=", "getBeanStore", "(", ")", ";", "if", "(", "beanStore", "==", "null", ")", "{", "throw", "ContextLogger", ".", "LOG", ".", "noBeanStoreAvailable", "(", "this", ")", ";", "}", "for", "(", "BeanIdentifier", "id", ":", "beanStore", ")", "{", "destroyContextualInstance", "(", "beanStore", ".", "get", "(", "id", ")", ")", ";", "}", "beanStore", ".", "clear", "(", ")", ";", "}" ]
Destroys the context
[ "Destroys", "the", "context" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/contexts/AbstractContext.java#L146-L156
163,254
weld/core
impl/src/main/java/org/jboss/weld/util/collections/Iterables.java
Iterables.addAll
public static <T> boolean addAll(Collection<T> target, Iterable<? extends T> iterable) { if (iterable instanceof Collection) { return target.addAll((Collection<? extends T>) iterable); } return Iterators.addAll(target, iterable.iterator()); }
java
public static <T> boolean addAll(Collection<T> target, Iterable<? extends T> iterable) { if (iterable instanceof Collection) { return target.addAll((Collection<? extends T>) iterable); } return Iterators.addAll(target, iterable.iterator()); }
[ "public", "static", "<", "T", ">", "boolean", "addAll", "(", "Collection", "<", "T", ">", "target", ",", "Iterable", "<", "?", "extends", "T", ">", "iterable", ")", "{", "if", "(", "iterable", "instanceof", "Collection", ")", "{", "return", "target", ".", "addAll", "(", "(", "Collection", "<", "?", "extends", "T", ">", ")", "iterable", ")", ";", "}", "return", "Iterators", ".", "addAll", "(", "target", ",", "iterable", ".", "iterator", "(", ")", ")", ";", "}" ]
Add all elements in the iterable to the collection. @param target @param iterable @return true if the target was modified, false otherwise
[ "Add", "all", "elements", "in", "the", "iterable", "to", "the", "collection", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/collections/Iterables.java#L41-L46
163,255
weld/core
impl/src/main/java/org/jboss/weld/manager/FieldProducerFactory.java
FieldProducerFactory.createProducer
@Override public <T> Producer<T> createProducer(final Bean<X> declaringBean, final Bean<T> bean, DisposalMethod<X, T> disposalMethod) { EnhancedAnnotatedField<T, X> enhancedField = getManager().getServices().get(MemberTransformer.class).loadEnhancedMember(field, getManager().getId()); return new ProducerFieldProducer<X, T>(enhancedField, disposalMethod) { @Override public AnnotatedField<X> getAnnotated() { return field; } @Override public BeanManagerImpl getBeanManager() { return getManager(); } @Override public Bean<X> getDeclaringBean() { return declaringBean; } @Override public Bean<T> getBean() { return bean; } }; }
java
@Override public <T> Producer<T> createProducer(final Bean<X> declaringBean, final Bean<T> bean, DisposalMethod<X, T> disposalMethod) { EnhancedAnnotatedField<T, X> enhancedField = getManager().getServices().get(MemberTransformer.class).loadEnhancedMember(field, getManager().getId()); return new ProducerFieldProducer<X, T>(enhancedField, disposalMethod) { @Override public AnnotatedField<X> getAnnotated() { return field; } @Override public BeanManagerImpl getBeanManager() { return getManager(); } @Override public Bean<X> getDeclaringBean() { return declaringBean; } @Override public Bean<T> getBean() { return bean; } }; }
[ "@", "Override", "public", "<", "T", ">", "Producer", "<", "T", ">", "createProducer", "(", "final", "Bean", "<", "X", ">", "declaringBean", ",", "final", "Bean", "<", "T", ">", "bean", ",", "DisposalMethod", "<", "X", ",", "T", ">", "disposalMethod", ")", "{", "EnhancedAnnotatedField", "<", "T", ",", "X", ">", "enhancedField", "=", "getManager", "(", ")", ".", "getServices", "(", ")", ".", "get", "(", "MemberTransformer", ".", "class", ")", ".", "loadEnhancedMember", "(", "field", ",", "getManager", "(", ")", ".", "getId", "(", ")", ")", ";", "return", "new", "ProducerFieldProducer", "<", "X", ",", "T", ">", "(", "enhancedField", ",", "disposalMethod", ")", "{", "@", "Override", "public", "AnnotatedField", "<", "X", ">", "getAnnotated", "(", ")", "{", "return", "field", ";", "}", "@", "Override", "public", "BeanManagerImpl", "getBeanManager", "(", ")", "{", "return", "getManager", "(", ")", ";", "}", "@", "Override", "public", "Bean", "<", "X", ">", "getDeclaringBean", "(", ")", "{", "return", "declaringBean", ";", "}", "@", "Override", "public", "Bean", "<", "T", ">", "getBean", "(", ")", "{", "return", "bean", ";", "}", "}", ";", "}" ]
Producers returned from this method are not validated. Internal use only.
[ "Producers", "returned", "from", "this", "method", "are", "not", "validated", ".", "Internal", "use", "only", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/manager/FieldProducerFactory.java#L43-L68
163,256
weld/core
environments/common/src/main/java/org/jboss/weld/environment/deployment/WeldDeployment.java
WeldDeployment.createAdditionalBeanDeploymentArchive
protected WeldBeanDeploymentArchive createAdditionalBeanDeploymentArchive() { WeldBeanDeploymentArchive additionalBda = new WeldBeanDeploymentArchive(ADDITIONAL_BDA_ID, Collections.synchronizedSet(new HashSet<String>()), null); additionalBda.getServices().addAll(getServices().entrySet()); beanDeploymentArchives.add(additionalBda); setBeanDeploymentArchivesAccessibility(); return additionalBda; }
java
protected WeldBeanDeploymentArchive createAdditionalBeanDeploymentArchive() { WeldBeanDeploymentArchive additionalBda = new WeldBeanDeploymentArchive(ADDITIONAL_BDA_ID, Collections.synchronizedSet(new HashSet<String>()), null); additionalBda.getServices().addAll(getServices().entrySet()); beanDeploymentArchives.add(additionalBda); setBeanDeploymentArchivesAccessibility(); return additionalBda; }
[ "protected", "WeldBeanDeploymentArchive", "createAdditionalBeanDeploymentArchive", "(", ")", "{", "WeldBeanDeploymentArchive", "additionalBda", "=", "new", "WeldBeanDeploymentArchive", "(", "ADDITIONAL_BDA_ID", ",", "Collections", ".", "synchronizedSet", "(", "new", "HashSet", "<", "String", ">", "(", ")", ")", ",", "null", ")", ";", "additionalBda", ".", "getServices", "(", ")", ".", "addAll", "(", "getServices", "(", ")", ".", "entrySet", "(", ")", ")", ";", "beanDeploymentArchives", ".", "add", "(", "additionalBda", ")", ";", "setBeanDeploymentArchivesAccessibility", "(", ")", ";", "return", "additionalBda", ";", "}" ]
Additional bean deployment archives are used for extentions, synthetic annotated types and beans which do not come from a bean archive. @param beanClass @return the additional bean deployment archive
[ "Additional", "bean", "deployment", "archives", "are", "used", "for", "extentions", "synthetic", "annotated", "types", "and", "beans", "which", "do", "not", "come", "from", "a", "bean", "archive", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/environments/common/src/main/java/org/jboss/weld/environment/deployment/WeldDeployment.java#L104-L110
163,257
weld/core
environments/common/src/main/java/org/jboss/weld/environment/deployment/WeldDeployment.java
WeldDeployment.setBeanDeploymentArchivesAccessibility
protected void setBeanDeploymentArchivesAccessibility() { for (WeldBeanDeploymentArchive beanDeploymentArchive : beanDeploymentArchives) { Set<WeldBeanDeploymentArchive> accessibleArchives = new HashSet<>(); for (WeldBeanDeploymentArchive candidate : beanDeploymentArchives) { if (candidate.equals(beanDeploymentArchive)) { continue; } accessibleArchives.add(candidate); } beanDeploymentArchive.setAccessibleBeanDeploymentArchives(accessibleArchives); } }
java
protected void setBeanDeploymentArchivesAccessibility() { for (WeldBeanDeploymentArchive beanDeploymentArchive : beanDeploymentArchives) { Set<WeldBeanDeploymentArchive> accessibleArchives = new HashSet<>(); for (WeldBeanDeploymentArchive candidate : beanDeploymentArchives) { if (candidate.equals(beanDeploymentArchive)) { continue; } accessibleArchives.add(candidate); } beanDeploymentArchive.setAccessibleBeanDeploymentArchives(accessibleArchives); } }
[ "protected", "void", "setBeanDeploymentArchivesAccessibility", "(", ")", "{", "for", "(", "WeldBeanDeploymentArchive", "beanDeploymentArchive", ":", "beanDeploymentArchives", ")", "{", "Set", "<", "WeldBeanDeploymentArchive", ">", "accessibleArchives", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "WeldBeanDeploymentArchive", "candidate", ":", "beanDeploymentArchives", ")", "{", "if", "(", "candidate", ".", "equals", "(", "beanDeploymentArchive", ")", ")", "{", "continue", ";", "}", "accessibleArchives", ".", "add", "(", "candidate", ")", ";", "}", "beanDeploymentArchive", ".", "setAccessibleBeanDeploymentArchives", "(", "accessibleArchives", ")", ";", "}", "}" ]
By default all bean archives see each other.
[ "By", "default", "all", "bean", "archives", "see", "each", "other", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/environments/common/src/main/java/org/jboss/weld/environment/deployment/WeldDeployment.java#L115-L126
163,258
weld/core
probe/core/src/main/java/org/jboss/weld/probe/Parsers.java
Parsers.parseType
static Type parseType(String value, ResourceLoader resourceLoader) { value = value.trim(); // Wildcards if (value.equals(WILDCARD)) { return WildcardTypeImpl.defaultInstance(); } if (value.startsWith(WILDCARD_EXTENDS)) { Type upperBound = parseType(value.substring(WILDCARD_EXTENDS.length(), value.length()), resourceLoader); if (upperBound == null) { return null; } return WildcardTypeImpl.withUpperBound(upperBound); } if (value.startsWith(WILDCARD_SUPER)) { Type lowerBound = parseType(value.substring(WILDCARD_SUPER.length(), value.length()), resourceLoader); if (lowerBound == null) { return null; } return WildcardTypeImpl.withLowerBound(lowerBound); } // Array if (value.contains(ARRAY)) { Type componentType = parseType(value.substring(0, value.indexOf(ARRAY)), resourceLoader); if (componentType == null) { return null; } return new GenericArrayTypeImpl(componentType); } int chevLeft = value.indexOf(CHEVRONS_LEFT); String rawValue = chevLeft < 0 ? value : value.substring(0, chevLeft); Class<?> rawRequiredType = tryLoadClass(rawValue, resourceLoader); if (rawRequiredType == null) { return null; } if (rawRequiredType.getTypeParameters().length == 0) { return rawRequiredType; } // Parameterized type int chevRight = value.lastIndexOf(CHEVRONS_RIGHT); if (chevRight < 0) { return null; } List<String> parts = split(value.substring(chevLeft + 1, chevRight), ',', CHEVRONS_LEFT.charAt(0), CHEVRONS_RIGHT.charAt(0)); Type[] typeParameters = new Type[parts.size()]; for (int i = 0; i < typeParameters.length; i++) { Type typeParam = parseType(parts.get(i), resourceLoader); if (typeParam == null) { return null; } typeParameters[i] = typeParam; } return new ParameterizedTypeImpl(rawRequiredType, typeParameters); }
java
static Type parseType(String value, ResourceLoader resourceLoader) { value = value.trim(); // Wildcards if (value.equals(WILDCARD)) { return WildcardTypeImpl.defaultInstance(); } if (value.startsWith(WILDCARD_EXTENDS)) { Type upperBound = parseType(value.substring(WILDCARD_EXTENDS.length(), value.length()), resourceLoader); if (upperBound == null) { return null; } return WildcardTypeImpl.withUpperBound(upperBound); } if (value.startsWith(WILDCARD_SUPER)) { Type lowerBound = parseType(value.substring(WILDCARD_SUPER.length(), value.length()), resourceLoader); if (lowerBound == null) { return null; } return WildcardTypeImpl.withLowerBound(lowerBound); } // Array if (value.contains(ARRAY)) { Type componentType = parseType(value.substring(0, value.indexOf(ARRAY)), resourceLoader); if (componentType == null) { return null; } return new GenericArrayTypeImpl(componentType); } int chevLeft = value.indexOf(CHEVRONS_LEFT); String rawValue = chevLeft < 0 ? value : value.substring(0, chevLeft); Class<?> rawRequiredType = tryLoadClass(rawValue, resourceLoader); if (rawRequiredType == null) { return null; } if (rawRequiredType.getTypeParameters().length == 0) { return rawRequiredType; } // Parameterized type int chevRight = value.lastIndexOf(CHEVRONS_RIGHT); if (chevRight < 0) { return null; } List<String> parts = split(value.substring(chevLeft + 1, chevRight), ',', CHEVRONS_LEFT.charAt(0), CHEVRONS_RIGHT.charAt(0)); Type[] typeParameters = new Type[parts.size()]; for (int i = 0; i < typeParameters.length; i++) { Type typeParam = parseType(parts.get(i), resourceLoader); if (typeParam == null) { return null; } typeParameters[i] = typeParam; } return new ParameterizedTypeImpl(rawRequiredType, typeParameters); }
[ "static", "Type", "parseType", "(", "String", "value", ",", "ResourceLoader", "resourceLoader", ")", "{", "value", "=", "value", ".", "trim", "(", ")", ";", "// Wildcards", "if", "(", "value", ".", "equals", "(", "WILDCARD", ")", ")", "{", "return", "WildcardTypeImpl", ".", "defaultInstance", "(", ")", ";", "}", "if", "(", "value", ".", "startsWith", "(", "WILDCARD_EXTENDS", ")", ")", "{", "Type", "upperBound", "=", "parseType", "(", "value", ".", "substring", "(", "WILDCARD_EXTENDS", ".", "length", "(", ")", ",", "value", ".", "length", "(", ")", ")", ",", "resourceLoader", ")", ";", "if", "(", "upperBound", "==", "null", ")", "{", "return", "null", ";", "}", "return", "WildcardTypeImpl", ".", "withUpperBound", "(", "upperBound", ")", ";", "}", "if", "(", "value", ".", "startsWith", "(", "WILDCARD_SUPER", ")", ")", "{", "Type", "lowerBound", "=", "parseType", "(", "value", ".", "substring", "(", "WILDCARD_SUPER", ".", "length", "(", ")", ",", "value", ".", "length", "(", ")", ")", ",", "resourceLoader", ")", ";", "if", "(", "lowerBound", "==", "null", ")", "{", "return", "null", ";", "}", "return", "WildcardTypeImpl", ".", "withLowerBound", "(", "lowerBound", ")", ";", "}", "// Array", "if", "(", "value", ".", "contains", "(", "ARRAY", ")", ")", "{", "Type", "componentType", "=", "parseType", "(", "value", ".", "substring", "(", "0", ",", "value", ".", "indexOf", "(", "ARRAY", ")", ")", ",", "resourceLoader", ")", ";", "if", "(", "componentType", "==", "null", ")", "{", "return", "null", ";", "}", "return", "new", "GenericArrayTypeImpl", "(", "componentType", ")", ";", "}", "int", "chevLeft", "=", "value", ".", "indexOf", "(", "CHEVRONS_LEFT", ")", ";", "String", "rawValue", "=", "chevLeft", "<", "0", "?", "value", ":", "value", ".", "substring", "(", "0", ",", "chevLeft", ")", ";", "Class", "<", "?", ">", "rawRequiredType", "=", "tryLoadClass", "(", "rawValue", ",", "resourceLoader", ")", ";", "if", "(", "rawRequiredType", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "rawRequiredType", ".", "getTypeParameters", "(", ")", ".", "length", "==", "0", ")", "{", "return", "rawRequiredType", ";", "}", "// Parameterized type", "int", "chevRight", "=", "value", ".", "lastIndexOf", "(", "CHEVRONS_RIGHT", ")", ";", "if", "(", "chevRight", "<", "0", ")", "{", "return", "null", ";", "}", "List", "<", "String", ">", "parts", "=", "split", "(", "value", ".", "substring", "(", "chevLeft", "+", "1", ",", "chevRight", ")", ",", "'", "'", ",", "CHEVRONS_LEFT", ".", "charAt", "(", "0", ")", ",", "CHEVRONS_RIGHT", ".", "charAt", "(", "0", ")", ")", ";", "Type", "[", "]", "typeParameters", "=", "new", "Type", "[", "parts", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "typeParameters", ".", "length", ";", "i", "++", ")", "{", "Type", "typeParam", "=", "parseType", "(", "parts", ".", "get", "(", "i", ")", ",", "resourceLoader", ")", ";", "if", "(", "typeParam", "==", "null", ")", "{", "return", "null", ";", "}", "typeParameters", "[", "i", "]", "=", "typeParam", ";", "}", "return", "new", "ParameterizedTypeImpl", "(", "rawRequiredType", ",", "typeParameters", ")", ";", "}" ]
Type variables are not supported. @param value @return the type
[ "Type", "variables", "are", "not", "supported", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/probe/core/src/main/java/org/jboss/weld/probe/Parsers.java#L70-L122
163,259
weld/core
environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/portlet/PortletSupport.java
PortletSupport.isPortletEnvSupported
public static boolean isPortletEnvSupported() { if (enabled == null) { synchronized (PortletSupport.class) { if (enabled == null) { try { PortletSupport.class.getClassLoader().loadClass("javax.portlet.PortletContext"); enabled = true; } catch (Throwable ignored) { enabled = false; } } } } return enabled; }
java
public static boolean isPortletEnvSupported() { if (enabled == null) { synchronized (PortletSupport.class) { if (enabled == null) { try { PortletSupport.class.getClassLoader().loadClass("javax.portlet.PortletContext"); enabled = true; } catch (Throwable ignored) { enabled = false; } } } } return enabled; }
[ "public", "static", "boolean", "isPortletEnvSupported", "(", ")", "{", "if", "(", "enabled", "==", "null", ")", "{", "synchronized", "(", "PortletSupport", ".", "class", ")", "{", "if", "(", "enabled", "==", "null", ")", "{", "try", "{", "PortletSupport", ".", "class", ".", "getClassLoader", "(", ")", ".", "loadClass", "(", "\"javax.portlet.PortletContext\"", ")", ";", "enabled", "=", "true", ";", "}", "catch", "(", "Throwable", "ignored", ")", "{", "enabled", "=", "false", ";", "}", "}", "}", "}", "return", "enabled", ";", "}" ]
Is portlet env supported. @return true if portlet env is supported, false otherwise
[ "Is", "portlet", "env", "supported", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/portlet/PortletSupport.java#L40-L54
163,260
weld/core
environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/portlet/PortletSupport.java
PortletSupport.getBeanManager
public static BeanManager getBeanManager(Object ctx) { return (BeanManager) javax.portlet.PortletContext.class.cast(ctx).getAttribute(WeldServletLifecycle.BEAN_MANAGER_ATTRIBUTE_NAME); }
java
public static BeanManager getBeanManager(Object ctx) { return (BeanManager) javax.portlet.PortletContext.class.cast(ctx).getAttribute(WeldServletLifecycle.BEAN_MANAGER_ATTRIBUTE_NAME); }
[ "public", "static", "BeanManager", "getBeanManager", "(", "Object", "ctx", ")", "{", "return", "(", "BeanManager", ")", "javax", ".", "portlet", ".", "PortletContext", ".", "class", ".", "cast", "(", "ctx", ")", ".", "getAttribute", "(", "WeldServletLifecycle", ".", "BEAN_MANAGER_ATTRIBUTE_NAME", ")", ";", "}" ]
Get bean manager from portlet context. @param ctx the portlet context @return bean manager if found
[ "Get", "bean", "manager", "from", "portlet", "context", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/environments/servlet/core/src/main/java/org/jboss/weld/environment/servlet/portlet/PortletSupport.java#L72-L74
163,261
weld/core
impl/src/main/java/org/jboss/weld/bootstrap/enablement/GlobalEnablementBuilder.java
GlobalEnablementBuilder.filter
private <T> List<Class<?>> filter(List<Class<?>> enabledClasses, List<Class<?>> globallyEnabledClasses, LogMessageCallback logMessageCallback, BeanDeployment deployment) { for (Iterator<Class<?>> iterator = enabledClasses.iterator(); iterator.hasNext(); ) { Class<?> enabledClass = iterator.next(); if (globallyEnabledClasses.contains(enabledClass)) { logMessageCallback.log(enabledClass, deployment.getBeanDeploymentArchive().getId()); iterator.remove(); } } return enabledClasses; }
java
private <T> List<Class<?>> filter(List<Class<?>> enabledClasses, List<Class<?>> globallyEnabledClasses, LogMessageCallback logMessageCallback, BeanDeployment deployment) { for (Iterator<Class<?>> iterator = enabledClasses.iterator(); iterator.hasNext(); ) { Class<?> enabledClass = iterator.next(); if (globallyEnabledClasses.contains(enabledClass)) { logMessageCallback.log(enabledClass, deployment.getBeanDeploymentArchive().getId()); iterator.remove(); } } return enabledClasses; }
[ "private", "<", "T", ">", "List", "<", "Class", "<", "?", ">", ">", "filter", "(", "List", "<", "Class", "<", "?", ">", ">", "enabledClasses", ",", "List", "<", "Class", "<", "?", ">", ">", "globallyEnabledClasses", ",", "LogMessageCallback", "logMessageCallback", ",", "BeanDeployment", "deployment", ")", "{", "for", "(", "Iterator", "<", "Class", "<", "?", ">", ">", "iterator", "=", "enabledClasses", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "Class", "<", "?", ">", "enabledClass", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "globallyEnabledClasses", ".", "contains", "(", "enabledClass", ")", ")", "{", "logMessageCallback", ".", "log", "(", "enabledClass", ",", "deployment", ".", "getBeanDeploymentArchive", "(", ")", ".", "getId", "(", ")", ")", ";", "iterator", ".", "remove", "(", ")", ";", "}", "}", "return", "enabledClasses", ";", "}" ]
Filter out interceptors and decorators which are also enabled globally. @param enabledClasses @param globallyEnabledClasses @param logMessageCallback @param deployment @return the filtered list
[ "Filter", "out", "interceptors", "and", "decorators", "which", "are", "also", "enabled", "globally", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bootstrap/enablement/GlobalEnablementBuilder.java#L270-L280
163,262
weld/core
impl/src/main/java/org/jboss/weld/resolution/TypeSafeResolver.java
TypeSafeResolver.resolve
public F resolve(R resolvable, boolean cache) { R wrappedResolvable = wrap(resolvable); if (cache) { return resolved.getValue(wrappedResolvable); } else { return resolverFunction.apply(wrappedResolvable); } }
java
public F resolve(R resolvable, boolean cache) { R wrappedResolvable = wrap(resolvable); if (cache) { return resolved.getValue(wrappedResolvable); } else { return resolverFunction.apply(wrappedResolvable); } }
[ "public", "F", "resolve", "(", "R", "resolvable", ",", "boolean", "cache", ")", "{", "R", "wrappedResolvable", "=", "wrap", "(", "resolvable", ")", ";", "if", "(", "cache", ")", "{", "return", "resolved", ".", "getValue", "(", "wrappedResolvable", ")", ";", "}", "else", "{", "return", "resolverFunction", ".", "apply", "(", "wrappedResolvable", ")", ";", "}", "}" ]
Get the possible beans for the given element @param resolvable The resolving criteria @return An unmodifiable set of matching beans
[ "Get", "the", "possible", "beans", "for", "the", "given", "element" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/resolution/TypeSafeResolver.java#L85-L92
163,263
weld/core
impl/src/main/java/org/jboss/weld/resolution/TypeSafeResolver.java
TypeSafeResolver.findMatching
private Set<T> findMatching(R resolvable) { Set<T> result = new HashSet<T>(); for (T bean : getAllBeans(resolvable)) { if (matches(resolvable, bean)) { result.add(bean); } } return result; }
java
private Set<T> findMatching(R resolvable) { Set<T> result = new HashSet<T>(); for (T bean : getAllBeans(resolvable)) { if (matches(resolvable, bean)) { result.add(bean); } } return result; }
[ "private", "Set", "<", "T", ">", "findMatching", "(", "R", "resolvable", ")", "{", "Set", "<", "T", ">", "result", "=", "new", "HashSet", "<", "T", ">", "(", ")", ";", "for", "(", "T", "bean", ":", "getAllBeans", "(", "resolvable", ")", ")", "{", "if", "(", "matches", "(", "resolvable", ",", "bean", ")", ")", "{", "result", ".", "add", "(", "bean", ")", ";", "}", "}", "return", "result", ";", "}" ]
Gets the matching beans for binding criteria from a list of beans @param resolvable the resolvable @return A set of filtered beans
[ "Gets", "the", "matching", "beans", "for", "binding", "criteria", "from", "a", "list", "of", "beans" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/resolution/TypeSafeResolver.java#L100-L108
163,264
weld/core
impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployerEnvironment.java
BeanDeployerEnvironment.resolveDisposalBeans
public <X> Set<DisposalMethod<X, ?>> resolveDisposalBeans(Set<Type> types, Set<Annotation> qualifiers, AbstractClassBean<X> declaringBean) { // We can always cache as this is only ever called by Weld where we avoid non-static inner classes for annotation literals Set<DisposalMethod<X, ?>> beans = cast(disposalMethodResolver.resolve(new ResolvableBuilder(manager).addTypes(types).addQualifiers(qualifiers).setDeclaringBean(declaringBean).create(), true)); resolvedDisposalBeans.addAll(beans); return Collections.unmodifiableSet(beans); }
java
public <X> Set<DisposalMethod<X, ?>> resolveDisposalBeans(Set<Type> types, Set<Annotation> qualifiers, AbstractClassBean<X> declaringBean) { // We can always cache as this is only ever called by Weld where we avoid non-static inner classes for annotation literals Set<DisposalMethod<X, ?>> beans = cast(disposalMethodResolver.resolve(new ResolvableBuilder(manager).addTypes(types).addQualifiers(qualifiers).setDeclaringBean(declaringBean).create(), true)); resolvedDisposalBeans.addAll(beans); return Collections.unmodifiableSet(beans); }
[ "public", "<", "X", ">", "Set", "<", "DisposalMethod", "<", "X", ",", "?", ">", ">", "resolveDisposalBeans", "(", "Set", "<", "Type", ">", "types", ",", "Set", "<", "Annotation", ">", "qualifiers", ",", "AbstractClassBean", "<", "X", ">", "declaringBean", ")", "{", "// We can always cache as this is only ever called by Weld where we avoid non-static inner classes for annotation literals", "Set", "<", "DisposalMethod", "<", "X", ",", "?", ">", ">", "beans", "=", "cast", "(", "disposalMethodResolver", ".", "resolve", "(", "new", "ResolvableBuilder", "(", "manager", ")", ".", "addTypes", "(", "types", ")", ".", "addQualifiers", "(", "qualifiers", ")", ".", "setDeclaringBean", "(", "declaringBean", ")", ".", "create", "(", ")", ",", "true", ")", ")", ";", "resolvedDisposalBeans", ".", "addAll", "(", "beans", ")", ";", "return", "Collections", ".", "unmodifiableSet", "(", "beans", ")", ";", "}" ]
Resolve the disposal method for the given producer method. Any resolved beans will be marked as such for the purpose of validating that all disposal methods are used. For internal use. @param types the types @param qualifiers The binding types to match @param declaringBean declaring bean @return The set of matching disposal methods
[ "Resolve", "the", "disposal", "method", "for", "the", "given", "producer", "method", ".", "Any", "resolved", "beans", "will", "be", "marked", "as", "such", "for", "the", "purpose", "of", "validating", "that", "all", "disposal", "methods", "are", "used", ".", "For", "internal", "use", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployerEnvironment.java#L297-L302
163,265
weld/core
modules/ejb/src/main/java/org/jboss/weld/module/ejb/SessionBeans.java
SessionBeans.getSessionBeanTypes
private static <T> Set<Type> getSessionBeanTypes(EnhancedAnnotated<T, ?> annotated, EjbDescriptor<T> ejbDescriptor) { ImmutableSet.Builder<Type> types = ImmutableSet.builder(); // session beans Map<Class<?>, Type> typeMap = new LinkedHashMap<Class<?>, Type>(); HierarchyDiscovery beanClassDiscovery = HierarchyDiscovery.forNormalizedType(ejbDescriptor.getBeanClass()); for (BusinessInterfaceDescriptor<?> businessInterfaceDescriptor : ejbDescriptor.getLocalBusinessInterfaces()) { // first we need to resolve the local interface Type resolvedLocalInterface = beanClassDiscovery.resolveType(Types.getCanonicalType(businessInterfaceDescriptor.getInterface())); SessionBeanHierarchyDiscovery interfaceDiscovery = new SessionBeanHierarchyDiscovery(resolvedLocalInterface); if (beanClassDiscovery.getTypeMap().containsKey(businessInterfaceDescriptor.getInterface())) { // WELD-1675 Only add types also included in Annotated.getTypeClosure() for (Entry<Class<?>, Type> entry : interfaceDiscovery.getTypeMap().entrySet()) { if (annotated.getTypeClosure().contains(entry.getValue())) { typeMap.put(entry.getKey(), entry.getValue()); } } } else { // Session bean class does not implement the business interface and @javax.ejb.Local applied to the session bean class typeMap.putAll(interfaceDiscovery.getTypeMap()); } } if (annotated.isAnnotationPresent(Typed.class)) { types.addAll(Beans.getTypedTypes(typeMap, annotated.getJavaClass(), annotated.getAnnotation(Typed.class))); } else { typeMap.put(Object.class, Object.class); types.addAll(typeMap.values()); } return Beans.getLegalBeanTypes(types.build(), annotated); }
java
private static <T> Set<Type> getSessionBeanTypes(EnhancedAnnotated<T, ?> annotated, EjbDescriptor<T> ejbDescriptor) { ImmutableSet.Builder<Type> types = ImmutableSet.builder(); // session beans Map<Class<?>, Type> typeMap = new LinkedHashMap<Class<?>, Type>(); HierarchyDiscovery beanClassDiscovery = HierarchyDiscovery.forNormalizedType(ejbDescriptor.getBeanClass()); for (BusinessInterfaceDescriptor<?> businessInterfaceDescriptor : ejbDescriptor.getLocalBusinessInterfaces()) { // first we need to resolve the local interface Type resolvedLocalInterface = beanClassDiscovery.resolveType(Types.getCanonicalType(businessInterfaceDescriptor.getInterface())); SessionBeanHierarchyDiscovery interfaceDiscovery = new SessionBeanHierarchyDiscovery(resolvedLocalInterface); if (beanClassDiscovery.getTypeMap().containsKey(businessInterfaceDescriptor.getInterface())) { // WELD-1675 Only add types also included in Annotated.getTypeClosure() for (Entry<Class<?>, Type> entry : interfaceDiscovery.getTypeMap().entrySet()) { if (annotated.getTypeClosure().contains(entry.getValue())) { typeMap.put(entry.getKey(), entry.getValue()); } } } else { // Session bean class does not implement the business interface and @javax.ejb.Local applied to the session bean class typeMap.putAll(interfaceDiscovery.getTypeMap()); } } if (annotated.isAnnotationPresent(Typed.class)) { types.addAll(Beans.getTypedTypes(typeMap, annotated.getJavaClass(), annotated.getAnnotation(Typed.class))); } else { typeMap.put(Object.class, Object.class); types.addAll(typeMap.values()); } return Beans.getLegalBeanTypes(types.build(), annotated); }
[ "private", "static", "<", "T", ">", "Set", "<", "Type", ">", "getSessionBeanTypes", "(", "EnhancedAnnotated", "<", "T", ",", "?", ">", "annotated", ",", "EjbDescriptor", "<", "T", ">", "ejbDescriptor", ")", "{", "ImmutableSet", ".", "Builder", "<", "Type", ">", "types", "=", "ImmutableSet", ".", "builder", "(", ")", ";", "// session beans", "Map", "<", "Class", "<", "?", ">", ",", "Type", ">", "typeMap", "=", "new", "LinkedHashMap", "<", "Class", "<", "?", ">", ",", "Type", ">", "(", ")", ";", "HierarchyDiscovery", "beanClassDiscovery", "=", "HierarchyDiscovery", ".", "forNormalizedType", "(", "ejbDescriptor", ".", "getBeanClass", "(", ")", ")", ";", "for", "(", "BusinessInterfaceDescriptor", "<", "?", ">", "businessInterfaceDescriptor", ":", "ejbDescriptor", ".", "getLocalBusinessInterfaces", "(", ")", ")", "{", "// first we need to resolve the local interface", "Type", "resolvedLocalInterface", "=", "beanClassDiscovery", ".", "resolveType", "(", "Types", ".", "getCanonicalType", "(", "businessInterfaceDescriptor", ".", "getInterface", "(", ")", ")", ")", ";", "SessionBeanHierarchyDiscovery", "interfaceDiscovery", "=", "new", "SessionBeanHierarchyDiscovery", "(", "resolvedLocalInterface", ")", ";", "if", "(", "beanClassDiscovery", ".", "getTypeMap", "(", ")", ".", "containsKey", "(", "businessInterfaceDescriptor", ".", "getInterface", "(", ")", ")", ")", "{", "// WELD-1675 Only add types also included in Annotated.getTypeClosure()", "for", "(", "Entry", "<", "Class", "<", "?", ">", ",", "Type", ">", "entry", ":", "interfaceDiscovery", ".", "getTypeMap", "(", ")", ".", "entrySet", "(", ")", ")", "{", "if", "(", "annotated", ".", "getTypeClosure", "(", ")", ".", "contains", "(", "entry", ".", "getValue", "(", ")", ")", ")", "{", "typeMap", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "}", "else", "{", "// Session bean class does not implement the business interface and @javax.ejb.Local applied to the session bean class", "typeMap", ".", "putAll", "(", "interfaceDiscovery", ".", "getTypeMap", "(", ")", ")", ";", "}", "}", "if", "(", "annotated", ".", "isAnnotationPresent", "(", "Typed", ".", "class", ")", ")", "{", "types", ".", "addAll", "(", "Beans", ".", "getTypedTypes", "(", "typeMap", ",", "annotated", ".", "getJavaClass", "(", ")", ",", "annotated", ".", "getAnnotation", "(", "Typed", ".", "class", ")", ")", ")", ";", "}", "else", "{", "typeMap", ".", "put", "(", "Object", ".", "class", ",", "Object", ".", "class", ")", ";", "types", ".", "addAll", "(", "typeMap", ".", "values", "(", ")", ")", ";", "}", "return", "Beans", ".", "getLegalBeanTypes", "(", "types", ".", "build", "(", ")", ",", "annotated", ")", ";", "}" ]
Bean types of a session bean.
[ "Bean", "types", "of", "a", "session", "bean", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/modules/ejb/src/main/java/org/jboss/weld/module/ejb/SessionBeans.java#L125-L153
163,266
weld/core
modules/ejb/src/main/java/org/jboss/weld/module/ejb/SessionBeanImpl.java
SessionBeanImpl.of
public static <T> SessionBean<T> of(BeanAttributes<T> attributes, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl beanManager, EnhancedAnnotatedType<T> type) { return new SessionBeanImpl<T>(attributes, type, ejbDescriptor, new StringBeanIdentifier(SessionBeans.createIdentifier(type, ejbDescriptor)), beanManager); }
java
public static <T> SessionBean<T> of(BeanAttributes<T> attributes, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl beanManager, EnhancedAnnotatedType<T> type) { return new SessionBeanImpl<T>(attributes, type, ejbDescriptor, new StringBeanIdentifier(SessionBeans.createIdentifier(type, ejbDescriptor)), beanManager); }
[ "public", "static", "<", "T", ">", "SessionBean", "<", "T", ">", "of", "(", "BeanAttributes", "<", "T", ">", "attributes", ",", "InternalEjbDescriptor", "<", "T", ">", "ejbDescriptor", ",", "BeanManagerImpl", "beanManager", ",", "EnhancedAnnotatedType", "<", "T", ">", "type", ")", "{", "return", "new", "SessionBeanImpl", "<", "T", ">", "(", "attributes", ",", "type", ",", "ejbDescriptor", ",", "new", "StringBeanIdentifier", "(", "SessionBeans", ".", "createIdentifier", "(", "type", ",", "ejbDescriptor", ")", ")", ",", "beanManager", ")", ";", "}" ]
Creates a simple, annotation defined Enterprise Web Bean using the annotations specified on type @param <T> The type @param beanManager the current manager @param type the AnnotatedType to use @return An Enterprise Web Bean
[ "Creates", "a", "simple", "annotation", "defined", "Enterprise", "Web", "Bean", "using", "the", "annotations", "specified", "on", "type" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/modules/ejb/src/main/java/org/jboss/weld/module/ejb/SessionBeanImpl.java#L76-L78
163,267
weld/core
modules/ejb/src/main/java/org/jboss/weld/module/ejb/SessionBeanImpl.java
SessionBeanImpl.checkConflictingRoles
protected void checkConflictingRoles() { if (getType().isAnnotationPresent(Interceptor.class)) { throw BeanLogger.LOG.ejbCannotBeInterceptor(getType()); } if (getType().isAnnotationPresent(Decorator.class)) { throw BeanLogger.LOG.ejbCannotBeDecorator(getType()); } }
java
protected void checkConflictingRoles() { if (getType().isAnnotationPresent(Interceptor.class)) { throw BeanLogger.LOG.ejbCannotBeInterceptor(getType()); } if (getType().isAnnotationPresent(Decorator.class)) { throw BeanLogger.LOG.ejbCannotBeDecorator(getType()); } }
[ "protected", "void", "checkConflictingRoles", "(", ")", "{", "if", "(", "getType", "(", ")", ".", "isAnnotationPresent", "(", "Interceptor", ".", "class", ")", ")", "{", "throw", "BeanLogger", ".", "LOG", ".", "ejbCannotBeInterceptor", "(", "getType", "(", ")", ")", ";", "}", "if", "(", "getType", "(", ")", ".", "isAnnotationPresent", "(", "Decorator", ".", "class", ")", ")", "{", "throw", "BeanLogger", ".", "LOG", ".", "ejbCannotBeDecorator", "(", "getType", "(", ")", ")", ";", "}", "}" ]
Validates for non-conflicting roles
[ "Validates", "for", "non", "-", "conflicting", "roles" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/modules/ejb/src/main/java/org/jboss/weld/module/ejb/SessionBeanImpl.java#L107-L114
163,268
weld/core
modules/ejb/src/main/java/org/jboss/weld/module/ejb/SessionBeanImpl.java
SessionBeanImpl.checkScopeAllowed
protected void checkScopeAllowed() { if (ejbDescriptor.isStateless() && !isDependent()) { throw BeanLogger.LOG.scopeNotAllowedOnStatelessSessionBean(getScope(), getType()); } if (ejbDescriptor.isSingleton() && !(isDependent() || getScope().equals(ApplicationScoped.class))) { throw BeanLogger.LOG.scopeNotAllowedOnSingletonBean(getScope(), getType()); } }
java
protected void checkScopeAllowed() { if (ejbDescriptor.isStateless() && !isDependent()) { throw BeanLogger.LOG.scopeNotAllowedOnStatelessSessionBean(getScope(), getType()); } if (ejbDescriptor.isSingleton() && !(isDependent() || getScope().equals(ApplicationScoped.class))) { throw BeanLogger.LOG.scopeNotAllowedOnSingletonBean(getScope(), getType()); } }
[ "protected", "void", "checkScopeAllowed", "(", ")", "{", "if", "(", "ejbDescriptor", ".", "isStateless", "(", ")", "&&", "!", "isDependent", "(", ")", ")", "{", "throw", "BeanLogger", ".", "LOG", ".", "scopeNotAllowedOnStatelessSessionBean", "(", "getScope", "(", ")", ",", "getType", "(", ")", ")", ";", "}", "if", "(", "ejbDescriptor", ".", "isSingleton", "(", ")", "&&", "!", "(", "isDependent", "(", ")", "||", "getScope", "(", ")", ".", "equals", "(", "ApplicationScoped", ".", "class", ")", ")", ")", "{", "throw", "BeanLogger", ".", "LOG", ".", "scopeNotAllowedOnSingletonBean", "(", "getScope", "(", ")", ",", "getType", "(", ")", ")", ";", "}", "}" ]
Check that the scope type is allowed by the stereotypes on the bean and the bean type
[ "Check", "that", "the", "scope", "type", "is", "allowed", "by", "the", "stereotypes", "on", "the", "bean", "and", "the", "bean", "type" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/modules/ejb/src/main/java/org/jboss/weld/module/ejb/SessionBeanImpl.java#L120-L127
163,269
weld/core
modules/ejb/src/main/java/org/jboss/weld/module/ejb/SessionBeanImpl.java
SessionBeanImpl.checkObserverMethods
protected void checkObserverMethods() { Collection<EnhancedAnnotatedMethod<?, ? super T>> observerMethods = BeanMethods.getObserverMethods(this.getEnhancedAnnotated()); Collection<EnhancedAnnotatedMethod<?, ? super T>> asyncObserverMethods = BeanMethods.getAsyncObserverMethods(this.getEnhancedAnnotated()); checkObserverMethods(observerMethods); checkObserverMethods(asyncObserverMethods); }
java
protected void checkObserverMethods() { Collection<EnhancedAnnotatedMethod<?, ? super T>> observerMethods = BeanMethods.getObserverMethods(this.getEnhancedAnnotated()); Collection<EnhancedAnnotatedMethod<?, ? super T>> asyncObserverMethods = BeanMethods.getAsyncObserverMethods(this.getEnhancedAnnotated()); checkObserverMethods(observerMethods); checkObserverMethods(asyncObserverMethods); }
[ "protected", "void", "checkObserverMethods", "(", ")", "{", "Collection", "<", "EnhancedAnnotatedMethod", "<", "?", ",", "?", "super", "T", ">", ">", "observerMethods", "=", "BeanMethods", ".", "getObserverMethods", "(", "this", ".", "getEnhancedAnnotated", "(", ")", ")", ";", "Collection", "<", "EnhancedAnnotatedMethod", "<", "?", ",", "?", "super", "T", ">", ">", "asyncObserverMethods", "=", "BeanMethods", ".", "getAsyncObserverMethods", "(", "this", ".", "getEnhancedAnnotated", "(", ")", ")", ";", "checkObserverMethods", "(", "observerMethods", ")", ";", "checkObserverMethods", "(", "asyncObserverMethods", ")", ";", "}" ]
If there are any observer methods, they must be static or business methods.
[ "If", "there", "are", "any", "observer", "methods", "they", "must", "be", "static", "or", "business", "methods", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/modules/ejb/src/main/java/org/jboss/weld/module/ejb/SessionBeanImpl.java#L203-L208
163,270
weld/core
impl/src/main/java/org/jboss/weld/bean/NewManagedBean.java
NewManagedBean.of
public static <T> NewManagedBean<T> of(BeanAttributes<T> attributes, EnhancedAnnotatedType<T> clazz, BeanManagerImpl beanManager) { return new NewManagedBean<T>(attributes, clazz, new StringBeanIdentifier(BeanIdentifiers.forNewManagedBean(clazz)), beanManager); }
java
public static <T> NewManagedBean<T> of(BeanAttributes<T> attributes, EnhancedAnnotatedType<T> clazz, BeanManagerImpl beanManager) { return new NewManagedBean<T>(attributes, clazz, new StringBeanIdentifier(BeanIdentifiers.forNewManagedBean(clazz)), beanManager); }
[ "public", "static", "<", "T", ">", "NewManagedBean", "<", "T", ">", "of", "(", "BeanAttributes", "<", "T", ">", "attributes", ",", "EnhancedAnnotatedType", "<", "T", ">", "clazz", ",", "BeanManagerImpl", "beanManager", ")", "{", "return", "new", "NewManagedBean", "<", "T", ">", "(", "attributes", ",", "clazz", ",", "new", "StringBeanIdentifier", "(", "BeanIdentifiers", ".", "forNewManagedBean", "(", "clazz", ")", ")", ",", "beanManager", ")", ";", "}" ]
Creates an instance of a NewSimpleBean from an annotated class @param clazz The annotated class @param beanManager The Bean manager @return a new NewSimpleBean instance
[ "Creates", "an", "instance", "of", "a", "NewSimpleBean", "from", "an", "annotated", "class" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bean/NewManagedBean.java#L39-L41
163,271
weld/core
modules/ejb/src/main/java/org/jboss/weld/module/ejb/EnterpriseBeanProxyMethodHandler.java
EnterpriseBeanProxyMethodHandler.invoke
@Override public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Throwable { if ("destroy".equals(method.getName()) && Marker.isMarker(0, method, args)) { if (bean.getEjbDescriptor().isStateful()) { if (!reference.isRemoved()) { reference.remove(); } } return null; } if (!bean.isClientCanCallRemoveMethods() && isRemoveMethod(method)) { throw BeanLogger.LOG.invalidRemoveMethodInvocation(method); } Class<?> businessInterface = getBusinessInterface(method); if (reference.isRemoved() && isToStringMethod(method)) { return businessInterface.getName() + " [REMOVED]"; } Object proxiedInstance = reference.getBusinessObject(businessInterface); if (!Modifier.isPublic(method.getModifiers())) { throw new EJBException("Not a business method " + method.toString() +". Do not call non-public methods on EJB's."); } Object returnValue = Reflections.invokeAndUnwrap(proxiedInstance, method, args); BeanLogger.LOG.callProxiedMethod(method, proxiedInstance, args, returnValue); return returnValue; }
java
@Override public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Throwable { if ("destroy".equals(method.getName()) && Marker.isMarker(0, method, args)) { if (bean.getEjbDescriptor().isStateful()) { if (!reference.isRemoved()) { reference.remove(); } } return null; } if (!bean.isClientCanCallRemoveMethods() && isRemoveMethod(method)) { throw BeanLogger.LOG.invalidRemoveMethodInvocation(method); } Class<?> businessInterface = getBusinessInterface(method); if (reference.isRemoved() && isToStringMethod(method)) { return businessInterface.getName() + " [REMOVED]"; } Object proxiedInstance = reference.getBusinessObject(businessInterface); if (!Modifier.isPublic(method.getModifiers())) { throw new EJBException("Not a business method " + method.toString() +". Do not call non-public methods on EJB's."); } Object returnValue = Reflections.invokeAndUnwrap(proxiedInstance, method, args); BeanLogger.LOG.callProxiedMethod(method, proxiedInstance, args, returnValue); return returnValue; }
[ "@", "Override", "public", "Object", "invoke", "(", "Object", "self", ",", "Method", "method", ",", "Method", "proceed", ",", "Object", "[", "]", "args", ")", "throws", "Throwable", "{", "if", "(", "\"destroy\"", ".", "equals", "(", "method", ".", "getName", "(", ")", ")", "&&", "Marker", ".", "isMarker", "(", "0", ",", "method", ",", "args", ")", ")", "{", "if", "(", "bean", ".", "getEjbDescriptor", "(", ")", ".", "isStateful", "(", ")", ")", "{", "if", "(", "!", "reference", ".", "isRemoved", "(", ")", ")", "{", "reference", ".", "remove", "(", ")", ";", "}", "}", "return", "null", ";", "}", "if", "(", "!", "bean", ".", "isClientCanCallRemoveMethods", "(", ")", "&&", "isRemoveMethod", "(", "method", ")", ")", "{", "throw", "BeanLogger", ".", "LOG", ".", "invalidRemoveMethodInvocation", "(", "method", ")", ";", "}", "Class", "<", "?", ">", "businessInterface", "=", "getBusinessInterface", "(", "method", ")", ";", "if", "(", "reference", ".", "isRemoved", "(", ")", "&&", "isToStringMethod", "(", "method", ")", ")", "{", "return", "businessInterface", ".", "getName", "(", ")", "+", "\" [REMOVED]\"", ";", "}", "Object", "proxiedInstance", "=", "reference", ".", "getBusinessObject", "(", "businessInterface", ")", ";", "if", "(", "!", "Modifier", ".", "isPublic", "(", "method", ".", "getModifiers", "(", ")", ")", ")", "{", "throw", "new", "EJBException", "(", "\"Not a business method \"", "+", "method", ".", "toString", "(", ")", "+", "\". Do not call non-public methods on EJB's.\"", ")", ";", "}", "Object", "returnValue", "=", "Reflections", ".", "invokeAndUnwrap", "(", "proxiedInstance", ",", "method", ",", "args", ")", ";", "BeanLogger", ".", "LOG", ".", "callProxiedMethod", "(", "method", ",", "proxiedInstance", ",", "args", ",", "returnValue", ")", ";", "return", "returnValue", ";", "}" ]
Looks up the EJB in the container and executes the method on it @param self the proxy instance. @param method the overridden method declared in the super class or interface. @param proceed the forwarder method for invoking the overridden method. It is null if the overridden method is abstract or declared in the interface. @param args an array of objects containing the values of the arguments passed in the method invocation on the proxy instance. If a parameter type is a primitive type, the type of the array element is a wrapper class. @return the resulting value of the method invocation. @throws Throwable if the method invocation fails.
[ "Looks", "up", "the", "EJB", "in", "the", "container", "and", "executes", "the", "method", "on", "it" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/modules/ejb/src/main/java/org/jboss/weld/module/ejb/EnterpriseBeanProxyMethodHandler.java#L111-L137
163,272
weld/core
modules/jta/src/main/java/org/jboss/weld/module/jta/TransactionalObserverNotifier.java
TransactionalObserverNotifier.deferNotification
private <T> void deferNotification(T event, final EventMetadata metadata, final ObserverMethod<? super T> observer, final List<DeferredEventNotification<?>> notifications) { TransactionPhase transactionPhase = observer.getTransactionPhase(); boolean before = transactionPhase.equals(TransactionPhase.BEFORE_COMPLETION); Status status = Status.valueOf(transactionPhase); notifications.add(new DeferredEventNotification<T>(contextId, event, metadata, observer, currentEventMetadata, status, before)); }
java
private <T> void deferNotification(T event, final EventMetadata metadata, final ObserverMethod<? super T> observer, final List<DeferredEventNotification<?>> notifications) { TransactionPhase transactionPhase = observer.getTransactionPhase(); boolean before = transactionPhase.equals(TransactionPhase.BEFORE_COMPLETION); Status status = Status.valueOf(transactionPhase); notifications.add(new DeferredEventNotification<T>(contextId, event, metadata, observer, currentEventMetadata, status, before)); }
[ "private", "<", "T", ">", "void", "deferNotification", "(", "T", "event", ",", "final", "EventMetadata", "metadata", ",", "final", "ObserverMethod", "<", "?", "super", "T", ">", "observer", ",", "final", "List", "<", "DeferredEventNotification", "<", "?", ">", ">", "notifications", ")", "{", "TransactionPhase", "transactionPhase", "=", "observer", ".", "getTransactionPhase", "(", ")", ";", "boolean", "before", "=", "transactionPhase", ".", "equals", "(", "TransactionPhase", ".", "BEFORE_COMPLETION", ")", ";", "Status", "status", "=", "Status", ".", "valueOf", "(", "transactionPhase", ")", ";", "notifications", ".", "add", "(", "new", "DeferredEventNotification", "<", "T", ">", "(", "contextId", ",", "event", ",", "metadata", ",", "observer", ",", "currentEventMetadata", ",", "status", ",", "before", ")", ")", ";", "}" ]
Defers an event for processing in a later phase of the current transaction. @param metadata The event object
[ "Defers", "an", "event", "for", "processing", "in", "a", "later", "phase", "of", "the", "current", "transaction", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/modules/jta/src/main/java/org/jboss/weld/module/jta/TransactionalObserverNotifier.java#L63-L69
163,273
weld/core
impl/src/main/java/org/jboss/weld/serialization/BeanIdentifierIndex.java
BeanIdentifierIndex.build
public void build(Set<Bean<?>> beans) { if (isBuilt()) { throw new IllegalStateException("BeanIdentifier index is already built!"); } if (beans.isEmpty()) { index = new BeanIdentifier[0]; reverseIndex = Collections.emptyMap(); indexHash = 0; indexBuilt.set(true); return; } List<BeanIdentifier> tempIndex = new ArrayList<BeanIdentifier>(beans.size()); for (Bean<?> bean : beans) { if (bean instanceof CommonBean<?>) { tempIndex.add(((CommonBean<?>) bean).getIdentifier()); } else if (bean instanceof PassivationCapable) { tempIndex.add(new StringBeanIdentifier(((PassivationCapable) bean).getId())); } } Collections.sort(tempIndex, new Comparator<BeanIdentifier>() { @Override public int compare(BeanIdentifier o1, BeanIdentifier o2) { return o1.asString().compareTo(o2.asString()); } }); index = tempIndex.toArray(new BeanIdentifier[tempIndex.size()]); ImmutableMap.Builder<BeanIdentifier, Integer> builder = ImmutableMap.builder(); for (int i = 0; i < index.length; i++) { builder.put(index[i], i); } reverseIndex = builder.build(); indexHash = Arrays.hashCode(index); if(BootstrapLogger.LOG.isDebugEnabled()) { BootstrapLogger.LOG.beanIdentifierIndexBuilt(getDebugInfo()); } indexBuilt.set(true); }
java
public void build(Set<Bean<?>> beans) { if (isBuilt()) { throw new IllegalStateException("BeanIdentifier index is already built!"); } if (beans.isEmpty()) { index = new BeanIdentifier[0]; reverseIndex = Collections.emptyMap(); indexHash = 0; indexBuilt.set(true); return; } List<BeanIdentifier> tempIndex = new ArrayList<BeanIdentifier>(beans.size()); for (Bean<?> bean : beans) { if (bean instanceof CommonBean<?>) { tempIndex.add(((CommonBean<?>) bean).getIdentifier()); } else if (bean instanceof PassivationCapable) { tempIndex.add(new StringBeanIdentifier(((PassivationCapable) bean).getId())); } } Collections.sort(tempIndex, new Comparator<BeanIdentifier>() { @Override public int compare(BeanIdentifier o1, BeanIdentifier o2) { return o1.asString().compareTo(o2.asString()); } }); index = tempIndex.toArray(new BeanIdentifier[tempIndex.size()]); ImmutableMap.Builder<BeanIdentifier, Integer> builder = ImmutableMap.builder(); for (int i = 0; i < index.length; i++) { builder.put(index[i], i); } reverseIndex = builder.build(); indexHash = Arrays.hashCode(index); if(BootstrapLogger.LOG.isDebugEnabled()) { BootstrapLogger.LOG.beanIdentifierIndexBuilt(getDebugInfo()); } indexBuilt.set(true); }
[ "public", "void", "build", "(", "Set", "<", "Bean", "<", "?", ">", ">", "beans", ")", "{", "if", "(", "isBuilt", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"BeanIdentifier index is already built!\"", ")", ";", "}", "if", "(", "beans", ".", "isEmpty", "(", ")", ")", "{", "index", "=", "new", "BeanIdentifier", "[", "0", "]", ";", "reverseIndex", "=", "Collections", ".", "emptyMap", "(", ")", ";", "indexHash", "=", "0", ";", "indexBuilt", ".", "set", "(", "true", ")", ";", "return", ";", "}", "List", "<", "BeanIdentifier", ">", "tempIndex", "=", "new", "ArrayList", "<", "BeanIdentifier", ">", "(", "beans", ".", "size", "(", ")", ")", ";", "for", "(", "Bean", "<", "?", ">", "bean", ":", "beans", ")", "{", "if", "(", "bean", "instanceof", "CommonBean", "<", "?", ">", ")", "{", "tempIndex", ".", "add", "(", "(", "(", "CommonBean", "<", "?", ">", ")", "bean", ")", ".", "getIdentifier", "(", ")", ")", ";", "}", "else", "if", "(", "bean", "instanceof", "PassivationCapable", ")", "{", "tempIndex", ".", "add", "(", "new", "StringBeanIdentifier", "(", "(", "(", "PassivationCapable", ")", "bean", ")", ".", "getId", "(", ")", ")", ")", ";", "}", "}", "Collections", ".", "sort", "(", "tempIndex", ",", "new", "Comparator", "<", "BeanIdentifier", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "BeanIdentifier", "o1", ",", "BeanIdentifier", "o2", ")", "{", "return", "o1", ".", "asString", "(", ")", ".", "compareTo", "(", "o2", ".", "asString", "(", ")", ")", ";", "}", "}", ")", ";", "index", "=", "tempIndex", ".", "toArray", "(", "new", "BeanIdentifier", "[", "tempIndex", ".", "size", "(", ")", "]", ")", ";", "ImmutableMap", ".", "Builder", "<", "BeanIdentifier", ",", "Integer", ">", "builder", "=", "ImmutableMap", ".", "builder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "index", ".", "length", ";", "i", "++", ")", "{", "builder", ".", "put", "(", "index", "[", "i", "]", ",", "i", ")", ";", "}", "reverseIndex", "=", "builder", ".", "build", "(", ")", ";", "indexHash", "=", "Arrays", ".", "hashCode", "(", "index", ")", ";", "if", "(", "BootstrapLogger", ".", "LOG", ".", "isDebugEnabled", "(", ")", ")", "{", "BootstrapLogger", ".", "LOG", ".", "beanIdentifierIndexBuilt", "(", "getDebugInfo", "(", ")", ")", ";", "}", "indexBuilt", ".", "set", "(", "true", ")", ";", "}" ]
Note that the index can only be built once. @param beans The set of beans the index should be built from, only instances of {@link CommonBean} and implementations of {@link PassivationCapable} are included @throws IllegalStateException If the index is built already
[ "Note", "that", "the", "index", "can", "only", "be", "built", "once", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/serialization/BeanIdentifierIndex.java#L100-L145
163,274
weld/core
impl/src/main/java/org/jboss/weld/event/FastEvent.java
FastEvent.of
public static <T> FastEvent<T> of(Class<T> type, BeanManagerImpl manager, ObserverNotifier notifier, Annotation... qualifiers) { ResolvedObservers<T> resolvedObserverMethods = notifier.<T> resolveObserverMethods(type, qualifiers); if (resolvedObserverMethods.isMetadataRequired()) { EventMetadata metadata = new EventMetadataImpl(type, null, qualifiers); CurrentEventMetadata metadataService = manager.getServices().get(CurrentEventMetadata.class); return new FastEventWithMetadataPropagation<T>(resolvedObserverMethods, metadata, metadataService); } else { return new FastEvent<T>(resolvedObserverMethods); } }
java
public static <T> FastEvent<T> of(Class<T> type, BeanManagerImpl manager, ObserverNotifier notifier, Annotation... qualifiers) { ResolvedObservers<T> resolvedObserverMethods = notifier.<T> resolveObserverMethods(type, qualifiers); if (resolvedObserverMethods.isMetadataRequired()) { EventMetadata metadata = new EventMetadataImpl(type, null, qualifiers); CurrentEventMetadata metadataService = manager.getServices().get(CurrentEventMetadata.class); return new FastEventWithMetadataPropagation<T>(resolvedObserverMethods, metadata, metadataService); } else { return new FastEvent<T>(resolvedObserverMethods); } }
[ "public", "static", "<", "T", ">", "FastEvent", "<", "T", ">", "of", "(", "Class", "<", "T", ">", "type", ",", "BeanManagerImpl", "manager", ",", "ObserverNotifier", "notifier", ",", "Annotation", "...", "qualifiers", ")", "{", "ResolvedObservers", "<", "T", ">", "resolvedObserverMethods", "=", "notifier", ".", "<", "T", ">", "resolveObserverMethods", "(", "type", ",", "qualifiers", ")", ";", "if", "(", "resolvedObserverMethods", ".", "isMetadataRequired", "(", ")", ")", "{", "EventMetadata", "metadata", "=", "new", "EventMetadataImpl", "(", "type", ",", "null", ",", "qualifiers", ")", ";", "CurrentEventMetadata", "metadataService", "=", "manager", ".", "getServices", "(", ")", ".", "get", "(", "CurrentEventMetadata", ".", "class", ")", ";", "return", "new", "FastEventWithMetadataPropagation", "<", "T", ">", "(", "resolvedObserverMethods", ",", "metadata", ",", "metadataService", ")", ";", "}", "else", "{", "return", "new", "FastEvent", "<", "T", ">", "(", "resolvedObserverMethods", ")", ";", "}", "}" ]
Constructs a new FastEvent instance @param type the event type @param manager the bean manager @param notifier the notifier to be used for observer method resolution @param qualifiers the event qualifiers @return
[ "Constructs", "a", "new", "FastEvent", "instance" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/event/FastEvent.java#L75-L84
163,275
weld/core
impl/src/main/java/org/jboss/weld/util/collections/ImmutableList.java
ImmutableList.copyOf
public static <T> List<T> copyOf(T[] elements) { Preconditions.checkNotNull(elements); return ofInternal(elements.clone()); }
java
public static <T> List<T> copyOf(T[] elements) { Preconditions.checkNotNull(elements); return ofInternal(elements.clone()); }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "copyOf", "(", "T", "[", "]", "elements", ")", "{", "Preconditions", ".", "checkNotNull", "(", "elements", ")", ";", "return", "ofInternal", "(", "elements", ".", "clone", "(", ")", ")", ";", "}" ]
Creates an immutable list that consists of the elements in the given array. A copy of the given array is used which means that any modifications to the given array will not affect the immutable list. @param elements the given array of elements @return an immutable list
[ "Creates", "an", "immutable", "list", "that", "consists", "of", "the", "elements", "in", "the", "given", "array", ".", "A", "copy", "of", "the", "given", "array", "is", "used", "which", "means", "that", "any", "modifications", "to", "the", "given", "array", "will", "not", "affect", "the", "immutable", "list", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/collections/ImmutableList.java#L66-L69
163,276
weld/core
impl/src/main/java/org/jboss/weld/util/collections/ImmutableList.java
ImmutableList.copyOf
public static <T> List<T> copyOf(Collection<T> source) { Preconditions.checkNotNull(source); if (source instanceof ImmutableList<?>) { return (ImmutableList<T>) source; } if (source.isEmpty()) { return Collections.emptyList(); } return ofInternal(source.toArray()); }
java
public static <T> List<T> copyOf(Collection<T> source) { Preconditions.checkNotNull(source); if (source instanceof ImmutableList<?>) { return (ImmutableList<T>) source; } if (source.isEmpty()) { return Collections.emptyList(); } return ofInternal(source.toArray()); }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "copyOf", "(", "Collection", "<", "T", ">", "source", ")", "{", "Preconditions", ".", "checkNotNull", "(", "source", ")", ";", "if", "(", "source", "instanceof", "ImmutableList", "<", "?", ">", ")", "{", "return", "(", "ImmutableList", "<", "T", ">", ")", "source", ";", "}", "if", "(", "source", ".", "isEmpty", "(", ")", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "return", "ofInternal", "(", "source", ".", "toArray", "(", ")", ")", ";", "}" ]
Creates an immutable list that consists of the elements in the given collection. If the given collection is already an immutable list, it is returned directly. @param source the given collection @return an immutable list
[ "Creates", "an", "immutable", "list", "that", "consists", "of", "the", "elements", "in", "the", "given", "collection", ".", "If", "the", "given", "collection", "is", "already", "an", "immutable", "list", "it", "is", "returned", "directly", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/collections/ImmutableList.java#L78-L87
163,277
weld/core
impl/src/main/java/org/jboss/weld/util/Interceptors.java
Interceptors.filterInterceptorBindings
public static Set<Annotation> filterInterceptorBindings(BeanManagerImpl beanManager, Collection<Annotation> annotations) { Set<Annotation> interceptorBindings = new InterceptorBindingSet(beanManager); for (Annotation annotation : annotations) { if (beanManager.isInterceptorBinding(annotation.annotationType())) { interceptorBindings.add(annotation); } } return interceptorBindings; }
java
public static Set<Annotation> filterInterceptorBindings(BeanManagerImpl beanManager, Collection<Annotation> annotations) { Set<Annotation> interceptorBindings = new InterceptorBindingSet(beanManager); for (Annotation annotation : annotations) { if (beanManager.isInterceptorBinding(annotation.annotationType())) { interceptorBindings.add(annotation); } } return interceptorBindings; }
[ "public", "static", "Set", "<", "Annotation", ">", "filterInterceptorBindings", "(", "BeanManagerImpl", "beanManager", ",", "Collection", "<", "Annotation", ">", "annotations", ")", "{", "Set", "<", "Annotation", ">", "interceptorBindings", "=", "new", "InterceptorBindingSet", "(", "beanManager", ")", ";", "for", "(", "Annotation", "annotation", ":", "annotations", ")", "{", "if", "(", "beanManager", ".", "isInterceptorBinding", "(", "annotation", ".", "annotationType", "(", ")", ")", ")", "{", "interceptorBindings", ".", "add", "(", "annotation", ")", ";", "}", "}", "return", "interceptorBindings", ";", "}" ]
Extracts a set of interceptor bindings from a collection of annotations. @param beanManager @param annotations @return
[ "Extracts", "a", "set", "of", "interceptor", "bindings", "from", "a", "collection", "of", "annotations", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/Interceptors.java#L54-L62
163,278
weld/core
impl/src/main/java/org/jboss/weld/util/Interceptors.java
Interceptors.flattenInterceptorBindings
public static Set<Annotation> flattenInterceptorBindings(EnhancedAnnotatedType<?> clazz, BeanManagerImpl beanManager, Collection<Annotation> annotations, boolean addTopLevelInterceptorBindings, boolean addInheritedInterceptorBindings) { Set<Annotation> flattenInterceptorBindings = new InterceptorBindingSet(beanManager); MetaAnnotationStore metaAnnotationStore = beanManager.getServices().get(MetaAnnotationStore.class); if (addTopLevelInterceptorBindings) { addInterceptorBindings(clazz, annotations, flattenInterceptorBindings, metaAnnotationStore); } if (addInheritedInterceptorBindings) { for (Annotation annotation : annotations) { addInheritedInterceptorBindings(clazz, annotation.annotationType(), metaAnnotationStore, flattenInterceptorBindings); } } return flattenInterceptorBindings; }
java
public static Set<Annotation> flattenInterceptorBindings(EnhancedAnnotatedType<?> clazz, BeanManagerImpl beanManager, Collection<Annotation> annotations, boolean addTopLevelInterceptorBindings, boolean addInheritedInterceptorBindings) { Set<Annotation> flattenInterceptorBindings = new InterceptorBindingSet(beanManager); MetaAnnotationStore metaAnnotationStore = beanManager.getServices().get(MetaAnnotationStore.class); if (addTopLevelInterceptorBindings) { addInterceptorBindings(clazz, annotations, flattenInterceptorBindings, metaAnnotationStore); } if (addInheritedInterceptorBindings) { for (Annotation annotation : annotations) { addInheritedInterceptorBindings(clazz, annotation.annotationType(), metaAnnotationStore, flattenInterceptorBindings); } } return flattenInterceptorBindings; }
[ "public", "static", "Set", "<", "Annotation", ">", "flattenInterceptorBindings", "(", "EnhancedAnnotatedType", "<", "?", ">", "clazz", ",", "BeanManagerImpl", "beanManager", ",", "Collection", "<", "Annotation", ">", "annotations", ",", "boolean", "addTopLevelInterceptorBindings", ",", "boolean", "addInheritedInterceptorBindings", ")", "{", "Set", "<", "Annotation", ">", "flattenInterceptorBindings", "=", "new", "InterceptorBindingSet", "(", "beanManager", ")", ";", "MetaAnnotationStore", "metaAnnotationStore", "=", "beanManager", ".", "getServices", "(", ")", ".", "get", "(", "MetaAnnotationStore", ".", "class", ")", ";", "if", "(", "addTopLevelInterceptorBindings", ")", "{", "addInterceptorBindings", "(", "clazz", ",", "annotations", ",", "flattenInterceptorBindings", ",", "metaAnnotationStore", ")", ";", "}", "if", "(", "addInheritedInterceptorBindings", ")", "{", "for", "(", "Annotation", "annotation", ":", "annotations", ")", "{", "addInheritedInterceptorBindings", "(", "clazz", ",", "annotation", ".", "annotationType", "(", ")", ",", "metaAnnotationStore", ",", "flattenInterceptorBindings", ")", ";", "}", "}", "return", "flattenInterceptorBindings", ";", "}" ]
Extracts a flat set of interception bindings from a given set of interceptor bindings. @param addTopLevelInterceptorBindings add top level interceptor bindings to the result set. @param addInheritedInterceptorBindings add inherited level interceptor bindings to the result set. @return
[ "Extracts", "a", "flat", "set", "of", "interception", "bindings", "from", "a", "given", "set", "of", "interceptor", "bindings", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/Interceptors.java#L71-L85
163,279
weld/core
impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
Validator.validateRIBean
protected void validateRIBean(CommonBean<?> bean, BeanManagerImpl beanManager, Collection<CommonBean<?>> specializedBeans) { validateGeneralBean(bean, beanManager); if (bean instanceof NewBean) { return; } if (bean instanceof DecorableBean) { validateDecorators(beanManager, (DecorableBean<?>) bean); } if ((bean instanceof AbstractClassBean<?>)) { AbstractClassBean<?> classBean = (AbstractClassBean<?>) bean; // validate CDI-defined interceptors if (classBean.hasInterceptors()) { validateInterceptors(beanManager, classBean); } } // for each producer bean validate its disposer method if (bean instanceof AbstractProducerBean<?, ?, ?>) { AbstractProducerBean<?, ?, ?> producerBean = Reflections.<AbstractProducerBean<?, ?, ?>> cast(bean); if (producerBean.getProducer() instanceof AbstractMemberProducer<?, ?>) { AbstractMemberProducer<?, ?> producer = Reflections.<AbstractMemberProducer<?, ?>> cast(producerBean .getProducer()); if (producer.getDisposalMethod() != null) { for (InjectionPoint ip : producer.getDisposalMethod().getInjectionPoints()) { // pass the producer bean instead of the disposal method bean validateInjectionPointForDefinitionErrors(ip, null, beanManager); validateMetadataInjectionPoint(ip, null, ValidatorLogger.INJECTION_INTO_DISPOSER_METHOD); validateEventMetadataInjectionPoint(ip); validateInjectionPointForDeploymentProblems(ip, null, beanManager); } } } } }
java
protected void validateRIBean(CommonBean<?> bean, BeanManagerImpl beanManager, Collection<CommonBean<?>> specializedBeans) { validateGeneralBean(bean, beanManager); if (bean instanceof NewBean) { return; } if (bean instanceof DecorableBean) { validateDecorators(beanManager, (DecorableBean<?>) bean); } if ((bean instanceof AbstractClassBean<?>)) { AbstractClassBean<?> classBean = (AbstractClassBean<?>) bean; // validate CDI-defined interceptors if (classBean.hasInterceptors()) { validateInterceptors(beanManager, classBean); } } // for each producer bean validate its disposer method if (bean instanceof AbstractProducerBean<?, ?, ?>) { AbstractProducerBean<?, ?, ?> producerBean = Reflections.<AbstractProducerBean<?, ?, ?>> cast(bean); if (producerBean.getProducer() instanceof AbstractMemberProducer<?, ?>) { AbstractMemberProducer<?, ?> producer = Reflections.<AbstractMemberProducer<?, ?>> cast(producerBean .getProducer()); if (producer.getDisposalMethod() != null) { for (InjectionPoint ip : producer.getDisposalMethod().getInjectionPoints()) { // pass the producer bean instead of the disposal method bean validateInjectionPointForDefinitionErrors(ip, null, beanManager); validateMetadataInjectionPoint(ip, null, ValidatorLogger.INJECTION_INTO_DISPOSER_METHOD); validateEventMetadataInjectionPoint(ip); validateInjectionPointForDeploymentProblems(ip, null, beanManager); } } } } }
[ "protected", "void", "validateRIBean", "(", "CommonBean", "<", "?", ">", "bean", ",", "BeanManagerImpl", "beanManager", ",", "Collection", "<", "CommonBean", "<", "?", ">", ">", "specializedBeans", ")", "{", "validateGeneralBean", "(", "bean", ",", "beanManager", ")", ";", "if", "(", "bean", "instanceof", "NewBean", ")", "{", "return", ";", "}", "if", "(", "bean", "instanceof", "DecorableBean", ")", "{", "validateDecorators", "(", "beanManager", ",", "(", "DecorableBean", "<", "?", ">", ")", "bean", ")", ";", "}", "if", "(", "(", "bean", "instanceof", "AbstractClassBean", "<", "?", ">", ")", ")", "{", "AbstractClassBean", "<", "?", ">", "classBean", "=", "(", "AbstractClassBean", "<", "?", ">", ")", "bean", ";", "// validate CDI-defined interceptors", "if", "(", "classBean", ".", "hasInterceptors", "(", ")", ")", "{", "validateInterceptors", "(", "beanManager", ",", "classBean", ")", ";", "}", "}", "// for each producer bean validate its disposer method", "if", "(", "bean", "instanceof", "AbstractProducerBean", "<", "?", ",", "?", ",", "?", ">", ")", "{", "AbstractProducerBean", "<", "?", ",", "?", ",", "?", ">", "producerBean", "=", "Reflections", ".", "<", "AbstractProducerBean", "<", "?", ",", "?", ",", "?", ">", ">", "cast", "(", "bean", ")", ";", "if", "(", "producerBean", ".", "getProducer", "(", ")", "instanceof", "AbstractMemberProducer", "<", "?", ",", "?", ">", ")", "{", "AbstractMemberProducer", "<", "?", ",", "?", ">", "producer", "=", "Reflections", ".", "<", "AbstractMemberProducer", "<", "?", ",", "?", ">", ">", "cast", "(", "producerBean", ".", "getProducer", "(", ")", ")", ";", "if", "(", "producer", ".", "getDisposalMethod", "(", ")", "!=", "null", ")", "{", "for", "(", "InjectionPoint", "ip", ":", "producer", ".", "getDisposalMethod", "(", ")", ".", "getInjectionPoints", "(", ")", ")", "{", "// pass the producer bean instead of the disposal method bean", "validateInjectionPointForDefinitionErrors", "(", "ip", ",", "null", ",", "beanManager", ")", ";", "validateMetadataInjectionPoint", "(", "ip", ",", "null", ",", "ValidatorLogger", ".", "INJECTION_INTO_DISPOSER_METHOD", ")", ";", "validateEventMetadataInjectionPoint", "(", "ip", ")", ";", "validateInjectionPointForDeploymentProblems", "(", "ip", ",", "null", ",", "beanManager", ")", ";", "}", "}", "}", "}", "}" ]
Validate an RIBean. This includes validating whether two beans specialize the same bean @param bean the bean to validate @param beanManager the current manager @param specializedBeans the existing specialized beans
[ "Validate", "an", "RIBean", ".", "This", "includes", "validating", "whether", "two", "beans", "specialize", "the", "same", "bean" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java#L163-L195
163,280
weld/core
impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
Validator.validateInjectionPoint
public void validateInjectionPoint(InjectionPoint ij, BeanManagerImpl beanManager) { validateInjectionPointForDefinitionErrors(ij, ij.getBean(), beanManager); validateMetadataInjectionPoint(ij, ij.getBean(), ValidatorLogger.INJECTION_INTO_NON_BEAN); validateEventMetadataInjectionPoint(ij); validateInjectionPointForDeploymentProblems(ij, ij.getBean(), beanManager); }
java
public void validateInjectionPoint(InjectionPoint ij, BeanManagerImpl beanManager) { validateInjectionPointForDefinitionErrors(ij, ij.getBean(), beanManager); validateMetadataInjectionPoint(ij, ij.getBean(), ValidatorLogger.INJECTION_INTO_NON_BEAN); validateEventMetadataInjectionPoint(ij); validateInjectionPointForDeploymentProblems(ij, ij.getBean(), beanManager); }
[ "public", "void", "validateInjectionPoint", "(", "InjectionPoint", "ij", ",", "BeanManagerImpl", "beanManager", ")", "{", "validateInjectionPointForDefinitionErrors", "(", "ij", ",", "ij", ".", "getBean", "(", ")", ",", "beanManager", ")", ";", "validateMetadataInjectionPoint", "(", "ij", ",", "ij", ".", "getBean", "(", ")", ",", "ValidatorLogger", ".", "INJECTION_INTO_NON_BEAN", ")", ";", "validateEventMetadataInjectionPoint", "(", "ij", ")", ";", "validateInjectionPointForDeploymentProblems", "(", "ij", ",", "ij", ".", "getBean", "(", ")", ",", "beanManager", ")", ";", "}" ]
Validate an injection point @param ij the injection point to validate @param beanManager the bean manager
[ "Validate", "an", "injection", "point" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java#L286-L291
163,281
weld/core
impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
Validator.validatePseudoScopedBean
private static void validatePseudoScopedBean(Bean<?> bean, BeanManagerImpl beanManager) { if (bean.getInjectionPoints().isEmpty()) { // Skip validation if there are no injection points (e.g. for classes which are not intended to be used as beans) return; } reallyValidatePseudoScopedBean(bean, beanManager, new LinkedHashSet<Object>(), new HashSet<Bean<?>>()); }
java
private static void validatePseudoScopedBean(Bean<?> bean, BeanManagerImpl beanManager) { if (bean.getInjectionPoints().isEmpty()) { // Skip validation if there are no injection points (e.g. for classes which are not intended to be used as beans) return; } reallyValidatePseudoScopedBean(bean, beanManager, new LinkedHashSet<Object>(), new HashSet<Bean<?>>()); }
[ "private", "static", "void", "validatePseudoScopedBean", "(", "Bean", "<", "?", ">", "bean", ",", "BeanManagerImpl", "beanManager", ")", "{", "if", "(", "bean", ".", "getInjectionPoints", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "// Skip validation if there are no injection points (e.g. for classes which are not intended to be used as beans)", "return", ";", "}", "reallyValidatePseudoScopedBean", "(", "bean", ",", "beanManager", ",", "new", "LinkedHashSet", "<", "Object", ">", "(", ")", ",", "new", "HashSet", "<", "Bean", "<", "?", ">", ">", "(", ")", ")", ";", "}" ]
Checks to make sure that pseudo scoped beans (i.e. @Dependent scoped beans) have no circular dependencies.
[ "Checks", "to", "make", "sure", "that", "pseudo", "scoped", "beans", "(", "i", ".", "e", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java#L923-L929
163,282
weld/core
impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
Validator.reallyValidatePseudoScopedBean
private static void reallyValidatePseudoScopedBean(Bean<?> bean, BeanManagerImpl beanManager, Set<Object> dependencyPath, Set<Bean<?>> validatedBeans) { // see if we have already seen this bean in the dependency path if (dependencyPath.contains(bean)) { // create a list that shows the path to the bean List<Object> realDependencyPath = new ArrayList<Object>(dependencyPath); realDependencyPath.add(bean); throw ValidatorLogger.LOG.pseudoScopedBeanHasCircularReferences(WeldCollections.toMultiRowString(realDependencyPath)); } if (validatedBeans.contains(bean)) { return; } dependencyPath.add(bean); for (InjectionPoint injectionPoint : bean.getInjectionPoints()) { if (!injectionPoint.isDelegate()) { dependencyPath.add(injectionPoint); validatePseudoScopedInjectionPoint(injectionPoint, beanManager, dependencyPath, validatedBeans); dependencyPath.remove(injectionPoint); } } if (bean instanceof DecorableBean<?>) { final List<Decorator<?>> decorators = Reflections.<DecorableBean<?>>cast(bean).getDecorators(); if (!decorators.isEmpty()) { for (final Decorator<?> decorator : decorators) { reallyValidatePseudoScopedBean(decorator, beanManager, dependencyPath, validatedBeans); } } } if (bean instanceof AbstractProducerBean<?, ?, ?> && !(bean instanceof EEResourceProducerField<?, ?>)) { AbstractProducerBean<?, ?, ?> producer = (AbstractProducerBean<?, ?, ?>) bean; if (!beanManager.isNormalScope(producer.getDeclaringBean().getScope()) && !producer.getAnnotated().isStatic()) { reallyValidatePseudoScopedBean(producer.getDeclaringBean(), beanManager, dependencyPath, validatedBeans); } } validatedBeans.add(bean); dependencyPath.remove(bean); }
java
private static void reallyValidatePseudoScopedBean(Bean<?> bean, BeanManagerImpl beanManager, Set<Object> dependencyPath, Set<Bean<?>> validatedBeans) { // see if we have already seen this bean in the dependency path if (dependencyPath.contains(bean)) { // create a list that shows the path to the bean List<Object> realDependencyPath = new ArrayList<Object>(dependencyPath); realDependencyPath.add(bean); throw ValidatorLogger.LOG.pseudoScopedBeanHasCircularReferences(WeldCollections.toMultiRowString(realDependencyPath)); } if (validatedBeans.contains(bean)) { return; } dependencyPath.add(bean); for (InjectionPoint injectionPoint : bean.getInjectionPoints()) { if (!injectionPoint.isDelegate()) { dependencyPath.add(injectionPoint); validatePseudoScopedInjectionPoint(injectionPoint, beanManager, dependencyPath, validatedBeans); dependencyPath.remove(injectionPoint); } } if (bean instanceof DecorableBean<?>) { final List<Decorator<?>> decorators = Reflections.<DecorableBean<?>>cast(bean).getDecorators(); if (!decorators.isEmpty()) { for (final Decorator<?> decorator : decorators) { reallyValidatePseudoScopedBean(decorator, beanManager, dependencyPath, validatedBeans); } } } if (bean instanceof AbstractProducerBean<?, ?, ?> && !(bean instanceof EEResourceProducerField<?, ?>)) { AbstractProducerBean<?, ?, ?> producer = (AbstractProducerBean<?, ?, ?>) bean; if (!beanManager.isNormalScope(producer.getDeclaringBean().getScope()) && !producer.getAnnotated().isStatic()) { reallyValidatePseudoScopedBean(producer.getDeclaringBean(), beanManager, dependencyPath, validatedBeans); } } validatedBeans.add(bean); dependencyPath.remove(bean); }
[ "private", "static", "void", "reallyValidatePseudoScopedBean", "(", "Bean", "<", "?", ">", "bean", ",", "BeanManagerImpl", "beanManager", ",", "Set", "<", "Object", ">", "dependencyPath", ",", "Set", "<", "Bean", "<", "?", ">", ">", "validatedBeans", ")", "{", "// see if we have already seen this bean in the dependency path", "if", "(", "dependencyPath", ".", "contains", "(", "bean", ")", ")", "{", "// create a list that shows the path to the bean", "List", "<", "Object", ">", "realDependencyPath", "=", "new", "ArrayList", "<", "Object", ">", "(", "dependencyPath", ")", ";", "realDependencyPath", ".", "add", "(", "bean", ")", ";", "throw", "ValidatorLogger", ".", "LOG", ".", "pseudoScopedBeanHasCircularReferences", "(", "WeldCollections", ".", "toMultiRowString", "(", "realDependencyPath", ")", ")", ";", "}", "if", "(", "validatedBeans", ".", "contains", "(", "bean", ")", ")", "{", "return", ";", "}", "dependencyPath", ".", "add", "(", "bean", ")", ";", "for", "(", "InjectionPoint", "injectionPoint", ":", "bean", ".", "getInjectionPoints", "(", ")", ")", "{", "if", "(", "!", "injectionPoint", ".", "isDelegate", "(", ")", ")", "{", "dependencyPath", ".", "add", "(", "injectionPoint", ")", ";", "validatePseudoScopedInjectionPoint", "(", "injectionPoint", ",", "beanManager", ",", "dependencyPath", ",", "validatedBeans", ")", ";", "dependencyPath", ".", "remove", "(", "injectionPoint", ")", ";", "}", "}", "if", "(", "bean", "instanceof", "DecorableBean", "<", "?", ">", ")", "{", "final", "List", "<", "Decorator", "<", "?", ">", ">", "decorators", "=", "Reflections", ".", "<", "DecorableBean", "<", "?", ">", ">", "cast", "(", "bean", ")", ".", "getDecorators", "(", ")", ";", "if", "(", "!", "decorators", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "final", "Decorator", "<", "?", ">", "decorator", ":", "decorators", ")", "{", "reallyValidatePseudoScopedBean", "(", "decorator", ",", "beanManager", ",", "dependencyPath", ",", "validatedBeans", ")", ";", "}", "}", "}", "if", "(", "bean", "instanceof", "AbstractProducerBean", "<", "?", ",", "?", ",", "?", ">", "&&", "!", "(", "bean", "instanceof", "EEResourceProducerField", "<", "?", ",", "?", ">", ")", ")", "{", "AbstractProducerBean", "<", "?", ",", "?", ",", "?", ">", "producer", "=", "(", "AbstractProducerBean", "<", "?", ",", "?", ",", "?", ">", ")", "bean", ";", "if", "(", "!", "beanManager", ".", "isNormalScope", "(", "producer", ".", "getDeclaringBean", "(", ")", ".", "getScope", "(", ")", ")", "&&", "!", "producer", ".", "getAnnotated", "(", ")", ".", "isStatic", "(", ")", ")", "{", "reallyValidatePseudoScopedBean", "(", "producer", ".", "getDeclaringBean", "(", ")", ",", "beanManager", ",", "dependencyPath", ",", "validatedBeans", ")", ";", "}", "}", "validatedBeans", ".", "add", "(", "bean", ")", ";", "dependencyPath", ".", "remove", "(", "bean", ")", ";", "}" ]
checks if a bean has been seen before in the dependencyPath. If not, it resolves the InjectionPoints and adds the resolved beans to the set of beans to be validated
[ "checks", "if", "a", "bean", "has", "been", "seen", "before", "in", "the", "dependencyPath", ".", "If", "not", "it", "resolves", "the", "InjectionPoints", "and", "adds", "the", "resolved", "beans", "to", "the", "set", "of", "beans", "to", "be", "validated" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java#L936-L971
163,283
weld/core
impl/src/main/java/org/jboss/weld/interceptor/proxy/InterceptionContext.java
InterceptionContext.forConstructorInterception
public static InterceptionContext forConstructorInterception(InterceptionModel interceptionModel, CreationalContext<?> ctx, BeanManagerImpl manager, SlimAnnotatedType<?> type) { return of(interceptionModel, ctx, manager, null, type); }
java
public static InterceptionContext forConstructorInterception(InterceptionModel interceptionModel, CreationalContext<?> ctx, BeanManagerImpl manager, SlimAnnotatedType<?> type) { return of(interceptionModel, ctx, manager, null, type); }
[ "public", "static", "InterceptionContext", "forConstructorInterception", "(", "InterceptionModel", "interceptionModel", ",", "CreationalContext", "<", "?", ">", "ctx", ",", "BeanManagerImpl", "manager", ",", "SlimAnnotatedType", "<", "?", ">", "type", ")", "{", "return", "of", "(", "interceptionModel", ",", "ctx", ",", "manager", ",", "null", ",", "type", ")", ";", "}" ]
The context returned by this method may be later reused for other interception types. @param interceptionModel @param ctx @param manager @param type @return the interception context to be used for the AroundConstruct chain
[ "The", "context", "returned", "by", "this", "method", "may", "be", "later", "reused", "for", "other", "interception", "types", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/interceptor/proxy/InterceptionContext.java#L68-L70
163,284
weld/core
impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java
DisposalMethod.getRequiredQualifiers
private Set<QualifierInstance> getRequiredQualifiers(EnhancedAnnotatedParameter<?, ? super X> enhancedDisposedParameter) { Set<Annotation> disposedParameterQualifiers = enhancedDisposedParameter.getMetaAnnotations(Qualifier.class); if (disposedParameterQualifiers.isEmpty()) { disposedParameterQualifiers = Collections.<Annotation> singleton(Default.Literal.INSTANCE); } return beanManager.getServices().get(MetaAnnotationStore.class).getQualifierInstances(disposedParameterQualifiers); }
java
private Set<QualifierInstance> getRequiredQualifiers(EnhancedAnnotatedParameter<?, ? super X> enhancedDisposedParameter) { Set<Annotation> disposedParameterQualifiers = enhancedDisposedParameter.getMetaAnnotations(Qualifier.class); if (disposedParameterQualifiers.isEmpty()) { disposedParameterQualifiers = Collections.<Annotation> singleton(Default.Literal.INSTANCE); } return beanManager.getServices().get(MetaAnnotationStore.class).getQualifierInstances(disposedParameterQualifiers); }
[ "private", "Set", "<", "QualifierInstance", ">", "getRequiredQualifiers", "(", "EnhancedAnnotatedParameter", "<", "?", ",", "?", "super", "X", ">", "enhancedDisposedParameter", ")", "{", "Set", "<", "Annotation", ">", "disposedParameterQualifiers", "=", "enhancedDisposedParameter", ".", "getMetaAnnotations", "(", "Qualifier", ".", "class", ")", ";", "if", "(", "disposedParameterQualifiers", ".", "isEmpty", "(", ")", ")", "{", "disposedParameterQualifiers", "=", "Collections", ".", "<", "Annotation", ">", "singleton", "(", "Default", ".", "Literal", ".", "INSTANCE", ")", ";", "}", "return", "beanManager", ".", "getServices", "(", ")", ".", "get", "(", "MetaAnnotationStore", ".", "class", ")", ".", "getQualifierInstances", "(", "disposedParameterQualifiers", ")", ";", "}" ]
A disposer method is bound to a producer if the producer is assignable to the disposed parameter. @param enhancedDisposedParameter @return the set of required qualifiers for the given disposed parameter
[ "A", "disposer", "method", "is", "bound", "to", "a", "producer", "if", "the", "producer", "is", "assignable", "to", "the", "disposed", "parameter", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java#L169-L175
163,285
weld/core
impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java
Reflections.getActualTypeArguments
public static Type[] getActualTypeArguments(Class<?> clazz) { Type type = Types.getCanonicalType(clazz); if (type instanceof ParameterizedType) { return ((ParameterizedType) type).getActualTypeArguments(); } else { return EMPTY_TYPES; } }
java
public static Type[] getActualTypeArguments(Class<?> clazz) { Type type = Types.getCanonicalType(clazz); if (type instanceof ParameterizedType) { return ((ParameterizedType) type).getActualTypeArguments(); } else { return EMPTY_TYPES; } }
[ "public", "static", "Type", "[", "]", "getActualTypeArguments", "(", "Class", "<", "?", ">", "clazz", ")", "{", "Type", "type", "=", "Types", ".", "getCanonicalType", "(", "clazz", ")", ";", "if", "(", "type", "instanceof", "ParameterizedType", ")", "{", "return", "(", "(", "ParameterizedType", ")", "type", ")", ".", "getActualTypeArguments", "(", ")", ";", "}", "else", "{", "return", "EMPTY_TYPES", ";", "}", "}" ]
Gets the actual type arguments of a class @param clazz The class to examine @return The type arguments
[ "Gets", "the", "actual", "type", "arguments", "of", "a", "class" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java#L229-L236
163,286
weld/core
impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java
Reflections.getActualTypeArguments
public static Type[] getActualTypeArguments(Type type) { Type resolvedType = Types.getCanonicalType(type); if (resolvedType instanceof ParameterizedType) { return ((ParameterizedType) resolvedType).getActualTypeArguments(); } else { return EMPTY_TYPES; } }
java
public static Type[] getActualTypeArguments(Type type) { Type resolvedType = Types.getCanonicalType(type); if (resolvedType instanceof ParameterizedType) { return ((ParameterizedType) resolvedType).getActualTypeArguments(); } else { return EMPTY_TYPES; } }
[ "public", "static", "Type", "[", "]", "getActualTypeArguments", "(", "Type", "type", ")", "{", "Type", "resolvedType", "=", "Types", ".", "getCanonicalType", "(", "type", ")", ";", "if", "(", "resolvedType", "instanceof", "ParameterizedType", ")", "{", "return", "(", "(", "ParameterizedType", ")", "resolvedType", ")", ".", "getActualTypeArguments", "(", ")", ";", "}", "else", "{", "return", "EMPTY_TYPES", ";", "}", "}" ]
Gets the actual type arguments of a Type @param type The type to examine @return The type arguments
[ "Gets", "the", "actual", "type", "arguments", "of", "a", "Type" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java#L244-L251
163,287
weld/core
impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java
Reflections.loadClass
public static <T> Class<T> loadClass(String className, ResourceLoader resourceLoader) { try { return cast(resourceLoader.classForName(className)); } catch (ResourceLoadingException e) { return null; } catch (SecurityException e) { return null; } }
java
public static <T> Class<T> loadClass(String className, ResourceLoader resourceLoader) { try { return cast(resourceLoader.classForName(className)); } catch (ResourceLoadingException e) { return null; } catch (SecurityException e) { return null; } }
[ "public", "static", "<", "T", ">", "Class", "<", "T", ">", "loadClass", "(", "String", "className", ",", "ResourceLoader", "resourceLoader", ")", "{", "try", "{", "return", "cast", "(", "resourceLoader", ".", "classForName", "(", "className", ")", ")", ";", "}", "catch", "(", "ResourceLoadingException", "e", ")", "{", "return", "null", ";", "}", "catch", "(", "SecurityException", "e", ")", "{", "return", "null", ";", "}", "}" ]
Tries to load a class using the specified ResourceLoader. Returns null if the class is not found. @param className @param resourceLoader @return the loaded class or null if the given class cannot be loaded
[ "Tries", "to", "load", "a", "class", "using", "the", "specified", "ResourceLoader", ".", "Returns", "null", "if", "the", "class", "is", "not", "found", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java#L343-L351
163,288
weld/core
impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java
Reflections.findDeclaredMethodByName
public static Method findDeclaredMethodByName(Class<?> clazz, String methodName) { for (Method method : AccessController.doPrivileged(new GetDeclaredMethodsAction(clazz))) { if (methodName.equals(method.getName())) { return method; } } return null; }
java
public static Method findDeclaredMethodByName(Class<?> clazz, String methodName) { for (Method method : AccessController.doPrivileged(new GetDeclaredMethodsAction(clazz))) { if (methodName.equals(method.getName())) { return method; } } return null; }
[ "public", "static", "Method", "findDeclaredMethodByName", "(", "Class", "<", "?", ">", "clazz", ",", "String", "methodName", ")", "{", "for", "(", "Method", "method", ":", "AccessController", ".", "doPrivileged", "(", "new", "GetDeclaredMethodsAction", "(", "clazz", ")", ")", ")", "{", "if", "(", "methodName", ".", "equals", "(", "method", ".", "getName", "(", ")", ")", ")", "{", "return", "method", ";", "}", "}", "return", "null", ";", "}" ]
Searches for a declared method with a given name. If the class declares multiple methods with the given name, there is no guarantee as of which methods is returned. Null is returned if the class does not declare a method with the given name. @param clazz the given class @param methodName the given method name @return method method with the given name declared by the given class or null if no such method exists
[ "Searches", "for", "a", "declared", "method", "with", "a", "given", "name", ".", "If", "the", "class", "declares", "multiple", "methods", "with", "the", "given", "name", "there", "is", "no", "guarantee", "as", "of", "which", "methods", "is", "returned", ".", "Null", "is", "returned", "if", "the", "class", "does", "not", "declare", "a", "method", "with", "the", "given", "name", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java#L440-L447
163,289
weld/core
environments/se/core/src/main/java/org/jboss/weld/environment/se/StartMain.java
StartMain.main
public static void main(String[] args) { try { new StartMain(args).go(); } catch(Throwable t) { WeldSELogger.LOG.error("Application exited with an exception", t); System.exit(1); } }
java
public static void main(String[] args) { try { new StartMain(args).go(); } catch(Throwable t) { WeldSELogger.LOG.error("Application exited with an exception", t); System.exit(1); } }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "try", "{", "new", "StartMain", "(", "args", ")", ".", "go", "(", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "WeldSELogger", ".", "LOG", ".", "error", "(", "\"Application exited with an exception\"", ",", "t", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "}" ]
The main method called from the command line. @param args the command line arguments
[ "The", "main", "method", "called", "from", "the", "command", "line", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/environments/se/core/src/main/java/org/jboss/weld/environment/se/StartMain.java#L55-L62
163,290
weld/core
impl/src/main/java/org/jboss/weld/contexts/CreationalContextImpl.java
CreationalContextImpl.release
public void release(Contextual<T> contextual, T instance) { synchronized (dependentInstances) { for (ContextualInstance<?> dependentInstance : dependentInstances) { // do not destroy contextual again, since it's just being destroyed if (contextual == null || !(dependentInstance.getContextual().equals(contextual))) { destroy(dependentInstance); } } } if (resourceReferences != null) { for (ResourceReference<?> reference : resourceReferences) { reference.release(); } } }
java
public void release(Contextual<T> contextual, T instance) { synchronized (dependentInstances) { for (ContextualInstance<?> dependentInstance : dependentInstances) { // do not destroy contextual again, since it's just being destroyed if (contextual == null || !(dependentInstance.getContextual().equals(contextual))) { destroy(dependentInstance); } } } if (resourceReferences != null) { for (ResourceReference<?> reference : resourceReferences) { reference.release(); } } }
[ "public", "void", "release", "(", "Contextual", "<", "T", ">", "contextual", ",", "T", "instance", ")", "{", "synchronized", "(", "dependentInstances", ")", "{", "for", "(", "ContextualInstance", "<", "?", ">", "dependentInstance", ":", "dependentInstances", ")", "{", "// do not destroy contextual again, since it's just being destroyed", "if", "(", "contextual", "==", "null", "||", "!", "(", "dependentInstance", ".", "getContextual", "(", ")", ".", "equals", "(", "contextual", ")", ")", ")", "{", "destroy", "(", "dependentInstance", ")", ";", "}", "}", "}", "if", "(", "resourceReferences", "!=", "null", ")", "{", "for", "(", "ResourceReference", "<", "?", ">", "reference", ":", "resourceReferences", ")", "{", "reference", ".", "release", "(", ")", ";", "}", "}", "}" ]
should not be public
[ "should", "not", "be", "public" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/contexts/CreationalContextImpl.java#L126-L140
163,291
weld/core
impl/src/main/java/org/jboss/weld/contexts/CreationalContextImpl.java
CreationalContextImpl.destroyDependentInstance
public boolean destroyDependentInstance(T instance) { synchronized (dependentInstances) { for (Iterator<ContextualInstance<?>> iterator = dependentInstances.iterator(); iterator.hasNext();) { ContextualInstance<?> contextualInstance = iterator.next(); if (contextualInstance.getInstance() == instance) { iterator.remove(); destroy(contextualInstance); return true; } } } return false; }
java
public boolean destroyDependentInstance(T instance) { synchronized (dependentInstances) { for (Iterator<ContextualInstance<?>> iterator = dependentInstances.iterator(); iterator.hasNext();) { ContextualInstance<?> contextualInstance = iterator.next(); if (contextualInstance.getInstance() == instance) { iterator.remove(); destroy(contextualInstance); return true; } } } return false; }
[ "public", "boolean", "destroyDependentInstance", "(", "T", "instance", ")", "{", "synchronized", "(", "dependentInstances", ")", "{", "for", "(", "Iterator", "<", "ContextualInstance", "<", "?", ">", ">", "iterator", "=", "dependentInstances", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "ContextualInstance", "<", "?", ">", "contextualInstance", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "contextualInstance", ".", "getInstance", "(", ")", "==", "instance", ")", "{", "iterator", ".", "remove", "(", ")", ";", "destroy", "(", "contextualInstance", ")", ";", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Destroys dependent instance @param instance @return true if the instance was destroyed, false otherwise
[ "Destroys", "dependent", "instance" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/contexts/CreationalContextImpl.java#L212-L224
163,292
weld/core
impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java
AbstractProducerBean.checkReturnValue
protected T checkReturnValue(T instance) { if (instance == null && !isDependent()) { throw BeanLogger.LOG.nullNotAllowedFromProducer(getProducer(), Formats.formatAsStackTraceElement(getAnnotated().getJavaMember())); } if (instance == null) { InjectionPoint injectionPoint = beanManager.getServices().get(CurrentInjectionPoint.class).peek(); if (injectionPoint != null) { Class<?> injectionPointRawType = Reflections.getRawType(injectionPoint.getType()); if (injectionPointRawType.isPrimitive()) { return cast(Defaults.getJlsDefaultValue(injectionPointRawType)); } } } if (instance != null && !(instance instanceof Serializable)) { if (beanManager.isPassivatingScope(getScope())) { throw BeanLogger.LOG.nonSerializableProductError(getProducer(), Formats.formatAsStackTraceElement(getAnnotated().getJavaMember())); } InjectionPoint injectionPoint = beanManager.getServices().get(CurrentInjectionPoint.class).peek(); if (injectionPoint != null && injectionPoint.getBean() != null && Beans.isPassivatingScope(injectionPoint.getBean(), beanManager)) { // Transient field is passivation capable injection point if (!(injectionPoint.getMember() instanceof Field) || !injectionPoint.isTransient()) { throw BeanLogger.LOG.unserializableProductInjectionError(this, Formats.formatAsStackTraceElement(getAnnotated().getJavaMember()), injectionPoint, Formats.formatAsStackTraceElement(injectionPoint.getMember())); } } } return instance; }
java
protected T checkReturnValue(T instance) { if (instance == null && !isDependent()) { throw BeanLogger.LOG.nullNotAllowedFromProducer(getProducer(), Formats.formatAsStackTraceElement(getAnnotated().getJavaMember())); } if (instance == null) { InjectionPoint injectionPoint = beanManager.getServices().get(CurrentInjectionPoint.class).peek(); if (injectionPoint != null) { Class<?> injectionPointRawType = Reflections.getRawType(injectionPoint.getType()); if (injectionPointRawType.isPrimitive()) { return cast(Defaults.getJlsDefaultValue(injectionPointRawType)); } } } if (instance != null && !(instance instanceof Serializable)) { if (beanManager.isPassivatingScope(getScope())) { throw BeanLogger.LOG.nonSerializableProductError(getProducer(), Formats.formatAsStackTraceElement(getAnnotated().getJavaMember())); } InjectionPoint injectionPoint = beanManager.getServices().get(CurrentInjectionPoint.class).peek(); if (injectionPoint != null && injectionPoint.getBean() != null && Beans.isPassivatingScope(injectionPoint.getBean(), beanManager)) { // Transient field is passivation capable injection point if (!(injectionPoint.getMember() instanceof Field) || !injectionPoint.isTransient()) { throw BeanLogger.LOG.unserializableProductInjectionError(this, Formats.formatAsStackTraceElement(getAnnotated().getJavaMember()), injectionPoint, Formats.formatAsStackTraceElement(injectionPoint.getMember())); } } } return instance; }
[ "protected", "T", "checkReturnValue", "(", "T", "instance", ")", "{", "if", "(", "instance", "==", "null", "&&", "!", "isDependent", "(", ")", ")", "{", "throw", "BeanLogger", ".", "LOG", ".", "nullNotAllowedFromProducer", "(", "getProducer", "(", ")", ",", "Formats", ".", "formatAsStackTraceElement", "(", "getAnnotated", "(", ")", ".", "getJavaMember", "(", ")", ")", ")", ";", "}", "if", "(", "instance", "==", "null", ")", "{", "InjectionPoint", "injectionPoint", "=", "beanManager", ".", "getServices", "(", ")", ".", "get", "(", "CurrentInjectionPoint", ".", "class", ")", ".", "peek", "(", ")", ";", "if", "(", "injectionPoint", "!=", "null", ")", "{", "Class", "<", "?", ">", "injectionPointRawType", "=", "Reflections", ".", "getRawType", "(", "injectionPoint", ".", "getType", "(", ")", ")", ";", "if", "(", "injectionPointRawType", ".", "isPrimitive", "(", ")", ")", "{", "return", "cast", "(", "Defaults", ".", "getJlsDefaultValue", "(", "injectionPointRawType", ")", ")", ";", "}", "}", "}", "if", "(", "instance", "!=", "null", "&&", "!", "(", "instance", "instanceof", "Serializable", ")", ")", "{", "if", "(", "beanManager", ".", "isPassivatingScope", "(", "getScope", "(", ")", ")", ")", "{", "throw", "BeanLogger", ".", "LOG", ".", "nonSerializableProductError", "(", "getProducer", "(", ")", ",", "Formats", ".", "formatAsStackTraceElement", "(", "getAnnotated", "(", ")", ".", "getJavaMember", "(", ")", ")", ")", ";", "}", "InjectionPoint", "injectionPoint", "=", "beanManager", ".", "getServices", "(", ")", ".", "get", "(", "CurrentInjectionPoint", ".", "class", ")", ".", "peek", "(", ")", ";", "if", "(", "injectionPoint", "!=", "null", "&&", "injectionPoint", ".", "getBean", "(", ")", "!=", "null", "&&", "Beans", ".", "isPassivatingScope", "(", "injectionPoint", ".", "getBean", "(", ")", ",", "beanManager", ")", ")", "{", "// Transient field is passivation capable injection point", "if", "(", "!", "(", "injectionPoint", ".", "getMember", "(", ")", "instanceof", "Field", ")", "||", "!", "injectionPoint", ".", "isTransient", "(", ")", ")", "{", "throw", "BeanLogger", ".", "LOG", ".", "unserializableProductInjectionError", "(", "this", ",", "Formats", ".", "formatAsStackTraceElement", "(", "getAnnotated", "(", ")", ".", "getJavaMember", "(", ")", ")", ",", "injectionPoint", ",", "Formats", ".", "formatAsStackTraceElement", "(", "injectionPoint", ".", "getMember", "(", ")", ")", ")", ";", "}", "}", "}", "return", "instance", ";", "}" ]
Validates the return value @param instance The instance to validate
[ "Validates", "the", "return", "value" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java#L134-L161
163,293
weld/core
impl/src/main/java/org/jboss/weld/util/collections/ImmutableMap.java
ImmutableMap.copyOf
public static <K, V> Map<K, V> copyOf(Map<K, V> map) { Preconditions.checkNotNull(map); return ImmutableMap.<K, V> builder().putAll(map).build(); }
java
public static <K, V> Map<K, V> copyOf(Map<K, V> map) { Preconditions.checkNotNull(map); return ImmutableMap.<K, V> builder().putAll(map).build(); }
[ "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "copyOf", "(", "Map", "<", "K", ",", "V", ">", "map", ")", "{", "Preconditions", ".", "checkNotNull", "(", "map", ")", ";", "return", "ImmutableMap", ".", "<", "K", ",", "V", ">", "builder", "(", ")", ".", "putAll", "(", "map", ")", ".", "build", "(", ")", ";", "}" ]
Creates an immutable map. A copy of the given map is used. As a result, it is safe to modify the source map afterwards. @param map the given map @return an immutable map
[ "Creates", "an", "immutable", "map", ".", "A", "copy", "of", "the", "given", "map", "is", "used", ".", "As", "a", "result", "it", "is", "safe", "to", "modify", "the", "source", "map", "afterwards", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/collections/ImmutableMap.java#L48-L51
163,294
weld/core
impl/src/main/java/org/jboss/weld/util/collections/ImmutableMap.java
ImmutableMap.of
public static <K, V> Map<K, V> of(K key, V value) { return new ImmutableMapEntry<K, V>(key, value); }
java
public static <K, V> Map<K, V> of(K key, V value) { return new ImmutableMapEntry<K, V>(key, value); }
[ "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "of", "(", "K", "key", ",", "V", "value", ")", "{", "return", "new", "ImmutableMapEntry", "<", "K", ",", "V", ">", "(", "key", ",", "value", ")", ";", "}" ]
Creates an immutable singleton instance. @param key @param value @return
[ "Creates", "an", "immutable", "singleton", "instance", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/collections/ImmutableMap.java#L60-L62
163,295
weld/core
impl/src/main/java/org/jboss/weld/util/reflection/Formats.java
Formats.formatAsStackTraceElement
public static String formatAsStackTraceElement(InjectionPoint ij) { Member member; if (ij.getAnnotated() instanceof AnnotatedField) { AnnotatedField<?> annotatedField = (AnnotatedField<?>) ij.getAnnotated(); member = annotatedField.getJavaMember(); } else if (ij.getAnnotated() instanceof AnnotatedParameter<?>) { AnnotatedParameter<?> annotatedParameter = (AnnotatedParameter<?>) ij.getAnnotated(); member = annotatedParameter.getDeclaringCallable().getJavaMember(); } else { // Not throwing an exception, because this method is invoked when an exception is already being thrown. // Throwing an exception here would hide the original exception. return "-"; } return formatAsStackTraceElement(member); }
java
public static String formatAsStackTraceElement(InjectionPoint ij) { Member member; if (ij.getAnnotated() instanceof AnnotatedField) { AnnotatedField<?> annotatedField = (AnnotatedField<?>) ij.getAnnotated(); member = annotatedField.getJavaMember(); } else if (ij.getAnnotated() instanceof AnnotatedParameter<?>) { AnnotatedParameter<?> annotatedParameter = (AnnotatedParameter<?>) ij.getAnnotated(); member = annotatedParameter.getDeclaringCallable().getJavaMember(); } else { // Not throwing an exception, because this method is invoked when an exception is already being thrown. // Throwing an exception here would hide the original exception. return "-"; } return formatAsStackTraceElement(member); }
[ "public", "static", "String", "formatAsStackTraceElement", "(", "InjectionPoint", "ij", ")", "{", "Member", "member", ";", "if", "(", "ij", ".", "getAnnotated", "(", ")", "instanceof", "AnnotatedField", ")", "{", "AnnotatedField", "<", "?", ">", "annotatedField", "=", "(", "AnnotatedField", "<", "?", ">", ")", "ij", ".", "getAnnotated", "(", ")", ";", "member", "=", "annotatedField", ".", "getJavaMember", "(", ")", ";", "}", "else", "if", "(", "ij", ".", "getAnnotated", "(", ")", "instanceof", "AnnotatedParameter", "<", "?", ">", ")", "{", "AnnotatedParameter", "<", "?", ">", "annotatedParameter", "=", "(", "AnnotatedParameter", "<", "?", ">", ")", "ij", ".", "getAnnotated", "(", ")", ";", "member", "=", "annotatedParameter", ".", "getDeclaringCallable", "(", ")", ".", "getJavaMember", "(", ")", ";", "}", "else", "{", "// Not throwing an exception, because this method is invoked when an exception is already being thrown.", "// Throwing an exception here would hide the original exception.", "return", "\"-\"", ";", "}", "return", "formatAsStackTraceElement", "(", "member", ")", ";", "}" ]
See also WELD-1454. @param ij @return the formatted string
[ "See", "also", "WELD", "-", "1454", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/reflection/Formats.java#L93-L107
163,296
weld/core
impl/src/main/java/org/jboss/weld/util/reflection/Formats.java
Formats.getLineNumber
public static int getLineNumber(Member member) { if (!(member instanceof Method || member instanceof Constructor)) { // We are not able to get this info for fields return 0; } // BCEL is an optional dependency, if we cannot load it, simply return 0 if (!Reflections.isClassLoadable(BCEL_CLASS, WeldClassLoaderResourceLoader.INSTANCE)) { return 0; } String classFile = member.getDeclaringClass().getName().replace('.', '/'); ClassLoaderResourceLoader classFileResourceLoader = new ClassLoaderResourceLoader(member.getDeclaringClass().getClassLoader()); InputStream in = null; try { URL classFileUrl = classFileResourceLoader.getResource(classFile + ".class"); if (classFileUrl == null) { // The class file is not available return 0; } in = classFileUrl.openStream(); ClassParser cp = new ClassParser(in, classFile); JavaClass javaClass = cp.parse(); // First get all declared methods and constructors // Note that in bytecode constructor is translated into a method org.apache.bcel.classfile.Method[] methods = javaClass.getMethods(); org.apache.bcel.classfile.Method match = null; String signature; String name; if (member instanceof Method) { signature = DescriptorUtils.methodDescriptor((Method) member); name = member.getName(); } else if (member instanceof Constructor) { signature = DescriptorUtils.makeDescriptor((Constructor<?>) member); name = INIT_METHOD_NAME; } else { return 0; } for (org.apache.bcel.classfile.Method method : methods) { // Matching method must have the same name, modifiers and signature if (method.getName().equals(name) && member.getModifiers() == method.getModifiers() && method.getSignature().equals(signature)) { match = method; } } if (match != null) { // If a method is found, try to obtain the optional LineNumberTable attribute LineNumberTable lineNumberTable = match.getLineNumberTable(); if (lineNumberTable != null) { int line = lineNumberTable.getSourceLine(0); return line == -1 ? 0 : line; } } // No suitable method found return 0; } catch (Throwable t) { return 0; } finally { if (in != null) { try { in.close(); } catch (Exception e) { return 0; } } } }
java
public static int getLineNumber(Member member) { if (!(member instanceof Method || member instanceof Constructor)) { // We are not able to get this info for fields return 0; } // BCEL is an optional dependency, if we cannot load it, simply return 0 if (!Reflections.isClassLoadable(BCEL_CLASS, WeldClassLoaderResourceLoader.INSTANCE)) { return 0; } String classFile = member.getDeclaringClass().getName().replace('.', '/'); ClassLoaderResourceLoader classFileResourceLoader = new ClassLoaderResourceLoader(member.getDeclaringClass().getClassLoader()); InputStream in = null; try { URL classFileUrl = classFileResourceLoader.getResource(classFile + ".class"); if (classFileUrl == null) { // The class file is not available return 0; } in = classFileUrl.openStream(); ClassParser cp = new ClassParser(in, classFile); JavaClass javaClass = cp.parse(); // First get all declared methods and constructors // Note that in bytecode constructor is translated into a method org.apache.bcel.classfile.Method[] methods = javaClass.getMethods(); org.apache.bcel.classfile.Method match = null; String signature; String name; if (member instanceof Method) { signature = DescriptorUtils.methodDescriptor((Method) member); name = member.getName(); } else if (member instanceof Constructor) { signature = DescriptorUtils.makeDescriptor((Constructor<?>) member); name = INIT_METHOD_NAME; } else { return 0; } for (org.apache.bcel.classfile.Method method : methods) { // Matching method must have the same name, modifiers and signature if (method.getName().equals(name) && member.getModifiers() == method.getModifiers() && method.getSignature().equals(signature)) { match = method; } } if (match != null) { // If a method is found, try to obtain the optional LineNumberTable attribute LineNumberTable lineNumberTable = match.getLineNumberTable(); if (lineNumberTable != null) { int line = lineNumberTable.getSourceLine(0); return line == -1 ? 0 : line; } } // No suitable method found return 0; } catch (Throwable t) { return 0; } finally { if (in != null) { try { in.close(); } catch (Exception e) { return 0; } } } }
[ "public", "static", "int", "getLineNumber", "(", "Member", "member", ")", "{", "if", "(", "!", "(", "member", "instanceof", "Method", "||", "member", "instanceof", "Constructor", ")", ")", "{", "// We are not able to get this info for fields", "return", "0", ";", "}", "// BCEL is an optional dependency, if we cannot load it, simply return 0", "if", "(", "!", "Reflections", ".", "isClassLoadable", "(", "BCEL_CLASS", ",", "WeldClassLoaderResourceLoader", ".", "INSTANCE", ")", ")", "{", "return", "0", ";", "}", "String", "classFile", "=", "member", ".", "getDeclaringClass", "(", ")", ".", "getName", "(", ")", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ";", "ClassLoaderResourceLoader", "classFileResourceLoader", "=", "new", "ClassLoaderResourceLoader", "(", "member", ".", "getDeclaringClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ";", "InputStream", "in", "=", "null", ";", "try", "{", "URL", "classFileUrl", "=", "classFileResourceLoader", ".", "getResource", "(", "classFile", "+", "\".class\"", ")", ";", "if", "(", "classFileUrl", "==", "null", ")", "{", "// The class file is not available", "return", "0", ";", "}", "in", "=", "classFileUrl", ".", "openStream", "(", ")", ";", "ClassParser", "cp", "=", "new", "ClassParser", "(", "in", ",", "classFile", ")", ";", "JavaClass", "javaClass", "=", "cp", ".", "parse", "(", ")", ";", "// First get all declared methods and constructors", "// Note that in bytecode constructor is translated into a method", "org", ".", "apache", ".", "bcel", ".", "classfile", ".", "Method", "[", "]", "methods", "=", "javaClass", ".", "getMethods", "(", ")", ";", "org", ".", "apache", ".", "bcel", ".", "classfile", ".", "Method", "match", "=", "null", ";", "String", "signature", ";", "String", "name", ";", "if", "(", "member", "instanceof", "Method", ")", "{", "signature", "=", "DescriptorUtils", ".", "methodDescriptor", "(", "(", "Method", ")", "member", ")", ";", "name", "=", "member", ".", "getName", "(", ")", ";", "}", "else", "if", "(", "member", "instanceof", "Constructor", ")", "{", "signature", "=", "DescriptorUtils", ".", "makeDescriptor", "(", "(", "Constructor", "<", "?", ">", ")", "member", ")", ";", "name", "=", "INIT_METHOD_NAME", ";", "}", "else", "{", "return", "0", ";", "}", "for", "(", "org", ".", "apache", ".", "bcel", ".", "classfile", ".", "Method", "method", ":", "methods", ")", "{", "// Matching method must have the same name, modifiers and signature", "if", "(", "method", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", "&&", "member", ".", "getModifiers", "(", ")", "==", "method", ".", "getModifiers", "(", ")", "&&", "method", ".", "getSignature", "(", ")", ".", "equals", "(", "signature", ")", ")", "{", "match", "=", "method", ";", "}", "}", "if", "(", "match", "!=", "null", ")", "{", "// If a method is found, try to obtain the optional LineNumberTable attribute", "LineNumberTable", "lineNumberTable", "=", "match", ".", "getLineNumberTable", "(", ")", ";", "if", "(", "lineNumberTable", "!=", "null", ")", "{", "int", "line", "=", "lineNumberTable", ".", "getSourceLine", "(", "0", ")", ";", "return", "line", "==", "-", "1", "?", "0", ":", "line", ";", "}", "}", "// No suitable method found", "return", "0", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "return", "0", ";", "}", "finally", "{", "if", "(", "in", "!=", "null", ")", "{", "try", "{", "in", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "0", ";", "}", "}", "}", "}" ]
Try to get the line number associated with the given member. The reflection API does not expose such an info and so we need to analyse the bytecode. Unfortunately, it seems there is no way to get this kind of information for fields. Moreover, the <code>LineNumberTable</code> attribute is just optional, i.e. the compiler is not required to store this information at all. See also <a href="http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.1">Java Virtual Machine Specification</a> Implementation note: it wouldn't be appropriate to add a bytecode scanning dependency just for this functionality, therefore Apache BCEL included in Oracle JDK 1.5+ and OpenJDK 1.6+ is used. Other JVMs should not crash as we only use it if it's on the classpath and by means of reflection calls. @param member @param resourceLoader @return the line number or 0 if it's not possible to find it
[ "Try", "to", "get", "the", "line", "number", "associated", "with", "the", "given", "member", "." ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/reflection/Formats.java#L129-L204
163,297
weld/core
impl/src/main/java/org/jboss/weld/util/reflection/Formats.java
Formats.parseModifiers
private static List<String> parseModifiers(int modifiers) { List<String> result = new ArrayList<String>(); if (Modifier.isPrivate(modifiers)) { result.add("private"); } if (Modifier.isProtected(modifiers)) { result.add("protected"); } if (Modifier.isPublic(modifiers)) { result.add("public"); } if (Modifier.isAbstract(modifiers)) { result.add("abstract"); } if (Modifier.isFinal(modifiers)) { result.add("final"); } if (Modifier.isNative(modifiers)) { result.add("native"); } if (Modifier.isStatic(modifiers)) { result.add("static"); } if (Modifier.isStrict(modifiers)) { result.add("strict"); } if (Modifier.isSynchronized(modifiers)) { result.add("synchronized"); } if (Modifier.isTransient(modifiers)) { result.add("transient"); } if (Modifier.isVolatile(modifiers)) { result.add("volatile"); } if (Modifier.isInterface(modifiers)) { result.add("interface"); } return result; }
java
private static List<String> parseModifiers(int modifiers) { List<String> result = new ArrayList<String>(); if (Modifier.isPrivate(modifiers)) { result.add("private"); } if (Modifier.isProtected(modifiers)) { result.add("protected"); } if (Modifier.isPublic(modifiers)) { result.add("public"); } if (Modifier.isAbstract(modifiers)) { result.add("abstract"); } if (Modifier.isFinal(modifiers)) { result.add("final"); } if (Modifier.isNative(modifiers)) { result.add("native"); } if (Modifier.isStatic(modifiers)) { result.add("static"); } if (Modifier.isStrict(modifiers)) { result.add("strict"); } if (Modifier.isSynchronized(modifiers)) { result.add("synchronized"); } if (Modifier.isTransient(modifiers)) { result.add("transient"); } if (Modifier.isVolatile(modifiers)) { result.add("volatile"); } if (Modifier.isInterface(modifiers)) { result.add("interface"); } return result; }
[ "private", "static", "List", "<", "String", ">", "parseModifiers", "(", "int", "modifiers", ")", "{", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "if", "(", "Modifier", ".", "isPrivate", "(", "modifiers", ")", ")", "{", "result", ".", "add", "(", "\"private\"", ")", ";", "}", "if", "(", "Modifier", ".", "isProtected", "(", "modifiers", ")", ")", "{", "result", ".", "add", "(", "\"protected\"", ")", ";", "}", "if", "(", "Modifier", ".", "isPublic", "(", "modifiers", ")", ")", "{", "result", ".", "add", "(", "\"public\"", ")", ";", "}", "if", "(", "Modifier", ".", "isAbstract", "(", "modifiers", ")", ")", "{", "result", ".", "add", "(", "\"abstract\"", ")", ";", "}", "if", "(", "Modifier", ".", "isFinal", "(", "modifiers", ")", ")", "{", "result", ".", "add", "(", "\"final\"", ")", ";", "}", "if", "(", "Modifier", ".", "isNative", "(", "modifiers", ")", ")", "{", "result", ".", "add", "(", "\"native\"", ")", ";", "}", "if", "(", "Modifier", ".", "isStatic", "(", "modifiers", ")", ")", "{", "result", ".", "add", "(", "\"static\"", ")", ";", "}", "if", "(", "Modifier", ".", "isStrict", "(", "modifiers", ")", ")", "{", "result", ".", "add", "(", "\"strict\"", ")", ";", "}", "if", "(", "Modifier", ".", "isSynchronized", "(", "modifiers", ")", ")", "{", "result", ".", "add", "(", "\"synchronized\"", ")", ";", "}", "if", "(", "Modifier", ".", "isTransient", "(", "modifiers", ")", ")", "{", "result", ".", "add", "(", "\"transient\"", ")", ";", "}", "if", "(", "Modifier", ".", "isVolatile", "(", "modifiers", ")", ")", "{", "result", ".", "add", "(", "\"volatile\"", ")", ";", "}", "if", "(", "Modifier", ".", "isInterface", "(", "modifiers", ")", ")", "{", "result", ".", "add", "(", "\"interface\"", ")", ";", "}", "return", "result", ";", "}" ]
Parses a reflection modifier to a list of string @param modifiers The modifier to parse @return The resulting string list
[ "Parses", "a", "reflection", "modifier", "to", "a", "list", "of", "string" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/reflection/Formats.java#L406-L445
163,298
weld/core
impl/src/main/java/org/jboss/weld/bootstrap/FastAnnotatedTypeLoader.java
FastAnnotatedTypeLoader.initCheckTypeModifiers
private boolean initCheckTypeModifiers() { Class<?> classInfoclass = Reflections.loadClass(CLASSINFO_CLASS_NAME, new ClassLoaderResourceLoader(classFileServices.getClass().getClassLoader())); if (classInfoclass != null) { try { Method setFlags = AccessController.doPrivileged(GetDeclaredMethodAction.of(classInfoclass, "setFlags", short.class)); return setFlags != null; } catch (Exception exceptionIgnored) { BootstrapLogger.LOG.usingOldJandexVersion(); return false; } } else { return true; } }
java
private boolean initCheckTypeModifiers() { Class<?> classInfoclass = Reflections.loadClass(CLASSINFO_CLASS_NAME, new ClassLoaderResourceLoader(classFileServices.getClass().getClassLoader())); if (classInfoclass != null) { try { Method setFlags = AccessController.doPrivileged(GetDeclaredMethodAction.of(classInfoclass, "setFlags", short.class)); return setFlags != null; } catch (Exception exceptionIgnored) { BootstrapLogger.LOG.usingOldJandexVersion(); return false; } } else { return true; } }
[ "private", "boolean", "initCheckTypeModifiers", "(", ")", "{", "Class", "<", "?", ">", "classInfoclass", "=", "Reflections", ".", "loadClass", "(", "CLASSINFO_CLASS_NAME", ",", "new", "ClassLoaderResourceLoader", "(", "classFileServices", ".", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ")", ";", "if", "(", "classInfoclass", "!=", "null", ")", "{", "try", "{", "Method", "setFlags", "=", "AccessController", ".", "doPrivileged", "(", "GetDeclaredMethodAction", ".", "of", "(", "classInfoclass", ",", "\"setFlags\"", ",", "short", ".", "class", ")", ")", ";", "return", "setFlags", "!=", "null", ";", "}", "catch", "(", "Exception", "exceptionIgnored", ")", "{", "BootstrapLogger", ".", "LOG", ".", "usingOldJandexVersion", "(", ")", ";", "return", "false", ";", "}", "}", "else", "{", "return", "true", ";", "}", "}" ]
checking availability of ClassInfo.setFlags method is just workaround for JANDEX-37
[ "checking", "availability", "of", "ClassInfo", ".", "setFlags", "method", "is", "just", "workaround", "for", "JANDEX", "-", "37" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bootstrap/FastAnnotatedTypeLoader.java#L132-L146
163,299
weld/core
impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java
ProducerMethod.of
public static <X, T> ProducerMethod<X, T> of(BeanAttributes<T> attributes, EnhancedAnnotatedMethod<T, ? super X> method, AbstractClassBean<X> declaringBean, DisposalMethod<X, ?> disposalMethod, BeanManagerImpl beanManager, ServiceRegistry services) { return new ProducerMethod<X, T>(createId(attributes, method, declaringBean), attributes, method, declaringBean, disposalMethod, beanManager, services); }
java
public static <X, T> ProducerMethod<X, T> of(BeanAttributes<T> attributes, EnhancedAnnotatedMethod<T, ? super X> method, AbstractClassBean<X> declaringBean, DisposalMethod<X, ?> disposalMethod, BeanManagerImpl beanManager, ServiceRegistry services) { return new ProducerMethod<X, T>(createId(attributes, method, declaringBean), attributes, method, declaringBean, disposalMethod, beanManager, services); }
[ "public", "static", "<", "X", ",", "T", ">", "ProducerMethod", "<", "X", ",", "T", ">", "of", "(", "BeanAttributes", "<", "T", ">", "attributes", ",", "EnhancedAnnotatedMethod", "<", "T", ",", "?", "super", "X", ">", "method", ",", "AbstractClassBean", "<", "X", ">", "declaringBean", ",", "DisposalMethod", "<", "X", ",", "?", ">", "disposalMethod", ",", "BeanManagerImpl", "beanManager", ",", "ServiceRegistry", "services", ")", "{", "return", "new", "ProducerMethod", "<", "X", ",", "T", ">", "(", "createId", "(", "attributes", ",", "method", ",", "declaringBean", ")", ",", "attributes", ",", "method", ",", "declaringBean", ",", "disposalMethod", ",", "beanManager", ",", "services", ")", ";", "}" ]
Creates a producer method Web Bean @param method The underlying method abstraction @param declaringBean The declaring bean abstraction @param beanManager the current manager @return A producer Web Bean
[ "Creates", "a", "producer", "method", "Web", "Bean" ]
567a2eaf95b168597d23a56be89bf05a7834b2aa
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java#L59-L61